Log user silences in the staff notes automatically
This commit is contained in:
parent
5f944944da
commit
30dc14de7d
|
@ -6,3 +6,4 @@ en:
|
|||
staff_notes:
|
||||
official_warning: "Received an official warning from @%{username} -- %{warning_link}"
|
||||
user_suspended: "@%{username} suspended this account until %{suspended_till}. Reason: %{reason}"
|
||||
user_silenced: "@%{username} silenced this account until %{silenced_till}. Reason: %{reason}"
|
||||
|
|
20
plugin.rb
20
plugin.rb
|
@ -236,4 +236,24 @@ after_initialize do
|
|||
)
|
||||
end
|
||||
|
||||
on(:user_silenced) do |details|
|
||||
raw_note = I18n.t(
|
||||
"staff_notes.user_silenced",
|
||||
username: details[:user].username,
|
||||
silenced_till: I18n.l(details[:silenced_till], format: :date_only),
|
||||
reason: details[:reason]
|
||||
)
|
||||
note_args = {}
|
||||
if post = Post.with_deleted.where(id: details[:post_id]).first
|
||||
note_args = { post_id: post.id, topic_id: post.topic_id }
|
||||
end
|
||||
|
||||
::DiscourseStaffNotes.add_note(
|
||||
details[:user],
|
||||
raw_note,
|
||||
Discourse::SYSTEM_USER_ID,
|
||||
note_args
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue