From 1a66feddcf357d704df26106cd7e61b3ddbbea4f Mon Sep 17 00:00:00 2001 From: nonamethanks Date: Tue, 22 Feb 2022 23:47:36 +0100 Subject: [PATCH] Moderation Reports: deprecate the forum topic --- app/models/moderation_report.rb | 38 ---------------------------- test/unit/moderation_reports_test.rb | 15 ----------- 2 files changed, 53 deletions(-) delete mode 100644 test/unit/moderation_reports_test.rb diff --git a/app/models/moderation_report.rb b/app/models/moderation_report.rb index 200311dd9..8c8b1efea 100644 --- a/app/models/moderation_report.rb +++ b/app/models/moderation_report.rb @@ -12,7 +12,6 @@ class ModerationReport < ApplicationRecord validates :model_type, inclusion: { in: MODEL_TYPES } validates :creator, uniqueness: { scope: [:model_type, :model_id], message: "have already reported this message." } - after_create :create_forum_post! after_create :autoban_reported_user after_save :notify_reporter after_save :create_modaction @@ -40,43 +39,6 @@ class ModerationReport < ApplicationRecord end end - def forum_topic_title - "Reports requiring moderation" - end - - def forum_topic_body - "This topic deals with moderation events as reported by Builders. Reports can be filed against users, comments, or forum posts." - end - - def forum_topic - topic = ForumTopic.find_by_title(forum_topic_title) - if topic.nil? - CurrentUser.scoped(User.system) do - topic = ForumTopic.create!(creator: User.system, title: forum_topic_title, category_id: 0, min_level: User::Levels::MODERATOR) - ForumPost.create!(creator: User.system, body: forum_topic_body, topic: topic) - end - end - topic - end - - def forum_post_message - <<~EOS - [b]Report[/b] modreport ##{id} - [b]Submitted by[/b] <@#{creator.name}> - [b]Submitted against[/b] #{model.dtext_shortlink(key: true)} by <@#{reported_user.name}> - [b]Reason[/b] #{reason} - - [quote] - #{model.body} - [/quote] - EOS - end - - def create_forum_post! - updater = ForumUpdater.new(forum_topic) - updater.update(forum_post_message) - end - def autoban_reported_user if SpamDetector.is_spammer?(reported_user) SpamDetector.ban_spammer!(reported_user) diff --git a/test/unit/moderation_reports_test.rb b/test/unit/moderation_reports_test.rb deleted file mode 100644 index c71411b1f..000000000 --- a/test/unit/moderation_reports_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'test_helper' - -class ModerationReportTest < ActiveSupport::TestCase - context "Moderation reports: " do - context "creating a moderation report" do - should "create a forum post" do - @dmail = create(:dmail) - @modreport = create(:moderation_report, model: @dmail, reason: "blah") - - assert_equal(2, ForumPost.count) - assert_match(/blah/, ForumPost.last.body) - end - end - end -end