mod reports: include reported user and message in forum post.

Also fix it so that reports against dmails include the key in the dmail
link so that mods can view the reported dmail.
This commit is contained in:
evazion
2020-02-03 04:42:09 -06:00
parent bb2022abed
commit 24cb920608
7 changed files with 36 additions and 12 deletions

View File

@@ -424,7 +424,7 @@ class ApplicationRecord < ActiveRecord::Base
end
concerning :DtextMethods do
def dtext_shortlink
def dtext_shortlink(**options)
"#{self.class.name.underscore.tr("_", " ")} ##{id}"
end
end

View File

@@ -191,4 +191,8 @@ class Dmail < ApplicationRecord
def reportable_by?(user)
is_recipient? && !is_automated? && !from.is_moderator?
end
def dtext_shortlink(key: false, **options)
key ? "dmail ##{id}/#{key}" : "dmail ##{id}"
end
end

View File

@@ -39,15 +39,16 @@ class ModerationReport < ApplicationRecord
end
def forum_post_message
messages = ["[b]Submitted by:[/b] @#{creator.name}"]
messages << "[b]Submitted against:[/b] #{model.dtext_shortlink}"
messages << ""
messages << "[quote]"
messages << "[b]Reason:[/b]"
messages << ""
messages << reason
messages << "[/quote]"
messages.join("\n")
<<~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!

View File

@@ -820,7 +820,7 @@ class User < ApplicationRecord
@presenter ||= UserPresenter.new(self)
end
def dtext_shortlink
def dtext_shortlink(**options)
"<@#{name}>"
end
end