From 87c6da740bca031f9fde1d4d8b830693345314c1 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 6 Sep 2020 16:24:26 -0400 Subject: [PATCH 01/14] Remove dead code --- app/controllers/api_controller.rb | 1 - app/controllers/dumps_controller.rb | 2 -- app/controllers/smoke_detectors_controller.rb | 20 +++--------------- app/controllers/users_controller.rb | 21 ------------------- .../users/migrate_token_confirmation.html.erb | 4 ---- config/config.sample.yml | 1 - db/migrate/20200906202319_drop_table_dumps.rb | 5 +++++ .../20200906202319_remove_api_token_legacy.rb | 6 ++++++ 8 files changed, 14 insertions(+), 46 deletions(-) delete mode 100644 app/views/users/migrate_token_confirmation.html.erb create mode 100644 db/migrate/20200906202319_drop_table_dumps.rb create mode 100644 db/migrate/20200906202319_remove_api_token_legacy.rb diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index b86cead7f..00ae01b56 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -2,7 +2,6 @@ class APIController < ApplicationController before_action :verify_key, except: %i[filter_generator api_docs filter_fields calculate_filter] - before_action :verify_trusted_key, only: [:regex_search] before_action :set_pagesize, except: %i[filter_generator api_docs] before_action :verify_write_token, only: %i[create_feedback report_post spam_flag add_domain_tag] skip_before_action :verify_authenticity_token, only: %i[posts_by_url create_feedback report_post spam_flag post_deleted add_domain_tag diff --git a/app/controllers/dumps_controller.rb b/app/controllers/dumps_controller.rb index 21ff777dd..f580c6c6e 100644 --- a/app/controllers/dumps_controller.rb +++ b/app/controllers/dumps_controller.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true class DumpsController < ApplicationController - before_action :set_dump, only: %i[show edit update destroy] - # GET /dumps # GET /dumps.json def index diff --git a/app/controllers/smoke_detectors_controller.rb b/app/controllers/smoke_detectors_controller.rb index a0586830b..6e482e33b 100644 --- a/app/controllers/smoke_detectors_controller.rb +++ b/app/controllers/smoke_detectors_controller.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true class SmokeDetectorsController < ApplicationController - before_action :authenticate_user!, except: %i[audits check_token] - before_action :verify_admin, except: %i[audits force_failover force_pull mine token_regen new create check_token] + before_action :authenticate_user!, except: :audits + before_action :verify_admin, except: %i[audits force_failover force_pull mine token_regen new create] before_action :verify_blacklist_manager, only: %i[force_failover force_pull] before_action :verify_smoke_detector_runner, only: %i[mine token_regen new create] - before_action :set_smoke_detector, except: %i[audits mine new create check_token] + before_action :set_smoke_detector, except: %i[audits mine new create] def destroy unless current_user.present? && (current_user.has_role?(:admin) || current_user.id == @smoke_detector.user_id) @@ -83,20 +83,6 @@ def token_regen redirect_to params[:redirect] || smoke_detector_mine_path end - # Used by Helios to verify new tokens - def check_token - token = SmokeDetector.where(access_token: params[:token]).first - payload = { - exists: token.present?, - owner_name: token&.user&.username, - location: token&.location, - created_at: token&.created_at, - updated_at: token&.updated_at - } - - render json: payload - end - private def set_smoke_detector diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ee0afcf77..3435f6302 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -132,27 +132,6 @@ def update_mod_sites redirect_to dev_user_path(@user) end - def migrate_token_confirmation - return unless params[:state] != Rails.cache.fetch("token_migration_state/#{current_user.id}") - flash[:danger] = "It looks like you didn't actually authenticate! It might still work, but I don't think it will." - end - - def migrate_token - state = Rails.cache.fetch("token_migration_state/#{current_user.id}") - res = HTTParty.get("#{AppConfig['token_store']['host']}/auth/confirm", - headers: { 'X-API-Key': AppConfig['token_store']['key'] }, - query: { account_id: current_user.stack_exchange_account_id, state: state }) - Rails.logger.info res - if params[:state] == state && JSON.parse(res.body)['token_exists'] && current_user.update(write_authenticated: true) - flash[:success] = 'Your registration was completed sucessfully!' - elsif params[:error].present? - flash[:danger] = "Got an error: #{params[:error]}: #{params[:error_description]}" - else - flash[:danger] = "We couldn't complete your registration. Please try again." - end - redirect_to edit_user_registration_path - end - private def set_user diff --git a/app/views/users/migrate_token_confirmation.html.erb b/app/views/users/migrate_token_confirmation.html.erb deleted file mode 100644 index a01d8dd06..000000000 --- a/app/views/users/migrate_token_confirmation.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= form_tag migrate_token_path do %> - <%= hidden_field_tag "state", params[:state] %> - <%= submit_tag "Confirm that you've granted access", class: 'btn btn-primary' %> -<% end %> diff --git a/config/config.sample.yml b/config/config.sample.yml index 6c8271268..0913731b8 100644 --- a/config/config.sample.yml +++ b/config/config.sample.yml @@ -236,7 +236,6 @@ common: &common - users.encrypted_password - users.reset_password_token - users.reset_password_sent_at - - users.encrypted_api_token - users.two_factor_token - users.salt - users.iv diff --git a/db/migrate/20200906202319_drop_table_dumps.rb b/db/migrate/20200906202319_drop_table_dumps.rb new file mode 100644 index 000000000..85d3da04c --- /dev/null +++ b/db/migrate/20200906202319_drop_table_dumps.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class DropTableDumps < ActiveRecord::Migration[5.2] + execute 'DROP TABLE dumps' +end diff --git a/db/migrate/20200906202319_remove_api_token_legacy.rb b/db/migrate/20200906202319_remove_api_token_legacy.rb new file mode 100644 index 000000000..f61665065 --- /dev/null +++ b/db/migrate/20200906202319_remove_api_token_legacy.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +class RemoveApiTokenLegacy < ActiveRecord::Migration[5.2] + remove_column :users, :encrypted_api_token_legacy + remove_column :users, :token_migrated_legacy +end From 455ca8dfbca2c1ca851053081db70661dcb4910d Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 6 Sep 2020 16:29:46 -0400 Subject: [PATCH 02/14] Remove non existent routing --- config/routes.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index fa002a90f..a21529986 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -470,9 +470,6 @@ get 'denied', to: 'users#missing_privileges', as: :missing_privileges - get 'migrate_token', to: 'users#migrate_token_confirmation', as: :migrate_token_confirmation - post 'migrate_token', to: 'users#migrate_token', as: :migrate_token - get ':id', to: 'users#show', as: :dev_user, constraints: { id: /-?\d+/ } post ':id/update_ids', to: 'users#refresh_ids', as: :update_user_chat_ids post ':id/reset_pass', to: 'users#send_password_reset', as: :send_password_reset From 610f4fdde33d253370d9b60bac75103940eb3821 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 6 Sep 2020 16:31:12 -0400 Subject: [PATCH 03/14] Use different timestamp --- ..._token_legacy.rb => 20200906202320_remove_api_token_legacy.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/migrate/{20200906202319_remove_api_token_legacy.rb => 20200906202320_remove_api_token_legacy.rb} (100%) diff --git a/db/migrate/20200906202319_remove_api_token_legacy.rb b/db/migrate/20200906202320_remove_api_token_legacy.rb similarity index 100% rename from db/migrate/20200906202319_remove_api_token_legacy.rb rename to db/migrate/20200906202320_remove_api_token_legacy.rb From 63b24cb833bf3dded26c1123d3a17d1b459290d4 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 6 Sep 2020 16:38:21 -0400 Subject: [PATCH 04/14] Make rake happy I have no idea why _api_ would become "API" rather than "Api" but anyways. --- db/migrate/20200906202320_remove_api_token_legacy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20200906202320_remove_api_token_legacy.rb b/db/migrate/20200906202320_remove_api_token_legacy.rb index f61665065..733a2cf65 100644 --- a/db/migrate/20200906202320_remove_api_token_legacy.rb +++ b/db/migrate/20200906202320_remove_api_token_legacy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class RemoveApiTokenLegacy < ActiveRecord::Migration[5.2] +class RemoveAPITokenLegacy < ActiveRecord::Migration[5.2] remove_column :users, :encrypted_api_token_legacy remove_column :users, :token_migrated_legacy end From dddd14a0cc7cd34fe873d9beb09c645ba5a88be7 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 6 Sep 2020 16:40:00 -0400 Subject: [PATCH 05/14] Remove more dead routings --- config/routes.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index a21529986..9942167c8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -419,7 +419,6 @@ post ':id/force_failover', to: 'smoke_detectors#force_failover', as: :smoke_detector_force_failover post ':id/force_pull', to: 'smoke_detectors#force_pull', as: :smoke_detector_force_pull get 'audits', to: 'smoke_detectors#audits' - get 'check_token/:token', to: 'smoke_detectors#check_token' end scope 'spammers' do From 7998d3d8657cbf51b42a83d2381d50f754a05959 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 6 Sep 2020 19:00:40 -0400 Subject: [PATCH 06/14] Remove non-existent "search reason" --- app/views/dashboard/index.html.erb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index cf5bdf9cd..2c426dd3a 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -1,9 +1,3 @@ -
-
- -
-
-

<%= @reasons.count %> <%= "filter".pluralize(@reasons.count) %> have caught From f7c3960f568da8ec0768475ea14eb838332d5268 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 6 Sep 2020 21:48:45 -0400 Subject: [PATCH 07/14] Remove obsolete full_dump() --- app/models/application_record.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 9a5bb7efd..75bb99744 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -69,14 +69,4 @@ def self.mass_habtm(join_table, first_type, second_type, record_pairs) def self.fields(*names) names.map { |n| "#{table_name}.#{n}" } end - - def self.full_dump - username = Rails.configuration.database_configuration[Rails.env]['username'] - password = Rails.configuration.database_configuration[Rails.env]['password'] - host = Rails.configuration.database_configuration[Rails.env]['host'] - `#{Rails.root}/dump/dump.sh "#{username}" "#{password}" "#{host}"` - - Dump.destroy_all - Dump.create file: File.open(Dir.glob('dumps/*')[0]) - end end From 6275377c3260e243ad34c068ca7fc8f782aca646 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 6 Sep 2020 21:53:26 -0400 Subject: [PATCH 08/14] Remove more obsolete/never used methods --- app/models/application_record.rb | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 75bb99744..31c31111c 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -3,11 +3,6 @@ class ApplicationRecord < ActiveRecord::Base self.abstract_class = true - def self.fuzzy_search(term, **cols) - sanitized = sanitize_for_search term, **cols - select(Arel.sql("`#{table_name}`.*, #{sanitized} AS search_score")) - end - def self.match_search(term, with_search_score: true, **cols) sanitized = sanitize_for_search term, **cols if with_search_score @@ -37,15 +32,6 @@ def self.sanitize_for_search(term, **cols) ActiveRecord::Base.send(:sanitize_sql_array, ["MATCH (#{cols}) AGAINST (? IN BOOLEAN MODE)", term]) end - # From http://stackoverflow.com/questions/6591722/how-to-generate-fixtures-based-on-my-development-database - def dump_fixture - fixture_file = "#{Rails.root}/test/fixtures/#{self.class.table_name}.yml" - File.open(fixture_file, 'a') do |f| - f.puts({ "#{self.class.table_name.singularize}_#{id}" => attributes } - .to_yaml.sub!(/---\s?/, "\n")) - end - end - def self.sanitize_like(unsafe, *args) sanitize_sql_like unsafe, *args end From 7f42342548be8360169195ca62aa0731720ed15f Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Mon, 7 Sep 2020 09:52:07 -0400 Subject: [PATCH 09/14] More dead code --- app/models/post.rb | 4 ---- app/models/reason.rb | 5 ----- app/models/user.rb | 9 --------- 3 files changed, 18 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index aa21e9504..0909beb3d 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -230,10 +230,6 @@ def deleted? deletion_logs.where(is_deleted: true).any? end - def conflicted? - is_tp && (is_fp || is_naa) - end - def stack_id native_id end diff --git a/app/models/reason.rb b/app/models/reason.rb index 046491ed6..735ff4ca9 100644 --- a/app/models/reason.rb +++ b/app/models/reason.rb @@ -39,9 +39,4 @@ def both_percentage count.to_f / posts.count end - - # Attempt to use cached post_count if it's available (included in the dashboard/index query) - def fast_post_count - try(:post_count) || posts.count - end end diff --git a/app/models/user.rb b/app/models/user.rb index 023889457..f25b06436 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -238,10 +238,6 @@ def spam_flag(post, dry_run = false) flag :spam, post, dry_run end - def abusive_flag(post, dry_run = false) - flag :abusive, post, dry_run - end - def other_flag(post, comment) flag :other, post, false, comment: comment end @@ -259,11 +255,6 @@ def add_pinned_role(name) end end - # rubocop:disable Style/PredicateName - def has_pinned_role?(role) - UsersRole.where(user: self, role: Role.find_by(name: role), pinned: true).exists? - end - def can_use_regex_search? (has_role? :reviewer) || moderator_sites.any? end From 9ee05ddc165b1a9e89392b503551ad28b13a64aa Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Mon, 7 Sep 2020 10:06:41 -0400 Subject: [PATCH 10/14] Remove indistinguishable 'pinned' roles --- app/controllers/admin_controller.rb | 6 +----- app/javascript/admin.js | 19 ------------------- app/models/user.rb | 9 --------- db/migrate/20200906202319_drop_table_dumps.rb | 4 +++- .../20200906202320_remove_api_token_legacy.rb | 6 ++++-- .../20200907140530_remove_pinned_role.rb | 7 +++++++ 6 files changed, 15 insertions(+), 36 deletions(-) create mode 100644 db/migrate/20200907140530_remove_pinned_role.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 6d6f812d6..bcb0f7f20 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -61,11 +61,7 @@ def update_permissions return end - if params[:pinned] - User.find(params[:user_id]).add_pinned_role params[:role] - else - User.find(params[:user_id]).add_role params[:role] - end + User.find(params[:user_id]).add_role params[:role] else User.find(params[:user_id]).remove_role params[:role] end diff --git a/app/javascript/admin.js b/app/javascript/admin.js index 15614c752..8d9a0e4fc 100644 --- a/app/javascript/admin.js +++ b/app/javascript/admin.js @@ -45,25 +45,6 @@ onLoad(() => { }); }); - $('input.pin-checkbox').change(function () { - const $this = $(this); - $this.disabled = true; - $.ajax({ - type: 'put', - data: { - permitted: $this.is(':checked'), - pinned: true, - user_id: $this.data('user-id'), - role: $this.data('role') - }, - dataType: 'json', - url: '/admin/permissions/update', - success() { - $this.disabled = false; - } - }); - }); - $('input.trust-checkbox').change(function () { const $this = $(this); $this.disabled = true; diff --git a/app/models/user.rb b/app/models/user.rb index f25b06436..6d44803d8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -246,15 +246,6 @@ def moderator? moderator_sites.any? end - def add_pinned_role(name) - role = Role.find_by name: name - if UsersRole.where(user: self, role: role).exists? - UsersRole.where(user: self, role: role).order(:user_id).last.update(pinned: true) - else - UsersRole.create(user: self, role: role, pinned: true) - end - end - def can_use_regex_search? (has_role? :reviewer) || moderator_sites.any? end diff --git a/db/migrate/20200906202319_drop_table_dumps.rb b/db/migrate/20200906202319_drop_table_dumps.rb index 85d3da04c..abf0a6d45 100644 --- a/db/migrate/20200906202319_drop_table_dumps.rb +++ b/db/migrate/20200906202319_drop_table_dumps.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true class DropTableDumps < ActiveRecord::Migration[5.2] - execute 'DROP TABLE dumps' + def change + execute 'DROP TABLE dumps' + end end diff --git a/db/migrate/20200906202320_remove_api_token_legacy.rb b/db/migrate/20200906202320_remove_api_token_legacy.rb index 733a2cf65..30ef9ba0f 100644 --- a/db/migrate/20200906202320_remove_api_token_legacy.rb +++ b/db/migrate/20200906202320_remove_api_token_legacy.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class RemoveAPITokenLegacy < ActiveRecord::Migration[5.2] - remove_column :users, :encrypted_api_token_legacy - remove_column :users, :token_migrated_legacy + def change + remove_column :users, :encrypted_api_token_legacy + remove_column :users, :token_migrated_legacy + end end diff --git a/db/migrate/20200907140530_remove_pinned_role.rb b/db/migrate/20200907140530_remove_pinned_role.rb new file mode 100644 index 000000000..2ffd94339 --- /dev/null +++ b/db/migrate/20200907140530_remove_pinned_role.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class RemovePinnedRole < ActiveRecord::Migration[5.2] + def change + remove_column :users_roles, :pinned + end +end From e0fbd0da235fe79b8f3cb1b6a149519308c3022a Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Mon, 7 Sep 2020 10:11:42 -0400 Subject: [PATCH 11/14] Revert "Remove non-existent "search reason"" This reverts commit 7998d3d8657cbf51b42a83d2381d50f754a05959. --- app/views/dashboard/index.html.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 2c426dd3a..cf5bdf9cd 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -1,3 +1,9 @@ +

+
+ +
+
+

<%= @reasons.count %> <%= "filter".pluralize(@reasons.count) %> have caught From fbe154ee53f06673bd47d3d9525dda608a6317f9 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Mon, 7 Sep 2020 10:18:50 -0400 Subject: [PATCH 12/14] Remove obsolete dump script --- dump/dump.sh | 19 ------------------- dump/redact.sql | 21 --------------------- 2 files changed, 40 deletions(-) delete mode 100755 dump/dump.sh delete mode 100644 dump/redact.sql diff --git a/dump/dump.sh b/dump/dump.sh deleted file mode 100755 index fc72ad53f..000000000 --- a/dump/dump.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -e - -METASMOKE_ROOT=/var/railsapps/metasmoke -timestamp=$(date +%s) -filename=dump_metasmoke_clean-$timestamp.sql.gz -username=$1 -password=$2 -host=$3 - -echo "CREATE DATABASE dump_metasmoke" | mysql -h $host -u $username --password=$password -mysqldump -h $host -u $username --password=$password metasmoke | mysql -h $host -u $username --password=$password dump_metasmoke; -mysql -h $host -u $username --password=$password dump_metasmoke < $METASMOKE_ROOT/current/dump/redact.sql -mysqldump -h $host -u $username --password=$password dump_metasmoke | gzip > $METASMOKE_ROOT/shared/dumps/$filename -echo "DROP DATABASE dump_metasmoke;" | mysql -h $host -u $username --password=$password - -# Remove old dumps -ls -d $METASMOKE_ROOT/shared/dumps/* | grep -v $filename | xargs rm diff --git a/dump/redact.sql b/dump/redact.sql deleted file mode 100644 index 3810a1c3e..000000000 --- a/dump/redact.sql +++ /dev/null @@ -1,21 +0,0 @@ -# Necessary for TRUNCATE calls to work properly. -SET FOREIGN_KEY_CHECKS=0; - -DROP TABLE `ar_internal_metadata`; -TRUNCATE TABLE `api_tokens`; -UPDATE `api_keys` SET `key` = ''; -UPDATE `audits` SET `remote_address` = ''; -TRUNCATE TABLE `emails_preferences`; -TRUNCATE TABLE `emails_addressees`; -TRUNCATE TABLE `flags`; -UPDATE `smoke_detectors` SET `access_token` = ''; -UPDATE `users` SET - `email` = CONCAT(`id`, '@metasmoke.fake'), - `encrypted_password` = '', - `reset_password_token` = '', - `reset_password_sent_at` = NULL, - `encrypted_api_token_legacy` = '', - `two_factor_token` = NULL, - `enabled_2fa` = NULL, - `salt` = NULL, - `iv` = NULL; From 060efe2dd50679196a65e7ca104d01ce2dbc50f1 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Mon, 7 Sep 2020 10:41:48 -0400 Subject: [PATCH 13/14] Not to delete some methods --- app/models/post.rb | 4 ++++ app/models/user.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/models/post.rb b/app/models/post.rb index 0909beb3d..aa21e9504 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -230,6 +230,10 @@ def deleted? deletion_logs.where(is_deleted: true).any? end + def conflicted? + is_tp && (is_fp || is_naa) + end + def stack_id native_id end diff --git a/app/models/user.rb b/app/models/user.rb index 6d44803d8..54f39af61 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -238,6 +238,10 @@ def spam_flag(post, dry_run = false) flag :spam, post, dry_run end + def abusive_flag(post, dry_run = false) + flag :abusive, post, dry_run + end + def other_flag(post, comment) flag :other, post, false, comment: comment end From 37636be1a214b4662de09bce7039329833984648 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Mon, 7 Sep 2020 10:44:37 -0400 Subject: [PATCH 14/14] Not to delete dump_fixture() --- app/models/application_record.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 31c31111c..99579a766 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -32,6 +32,15 @@ def self.sanitize_for_search(term, **cols) ActiveRecord::Base.send(:sanitize_sql_array, ["MATCH (#{cols}) AGAINST (? IN BOOLEAN MODE)", term]) end + # From http://stackoverflow.com/questions/6591722/how-to-generate-fixtures-based-on-my-development-database + def dump_fixture + fixture_file = "#{Rails.root}/test/fixtures/#{self.class.table_name}.yml" + File.open(fixture_file, 'a') do |f| + f.puts({ "#{self.class.table_name.singularize}_#{id}" => attributes } + .to_yaml.sub!(/---\s?/, "\n")) + end + end + def self.sanitize_like(unsafe, *args) sanitize_sql_like unsafe, *args end