Moderation Reports: deprecate the forum topic
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user