DEV: Expose silencer customization options to plugins (#11456)

Passes by_user to :user_unsilenced so plugins can detect whether or not
a silence was done automatically (by system user) or manually (by non-system)

Adds the ability to pass details in the action logger params so custom loggers
can pass their own details eg, in custom silence logs
This commit is contained in:
Jeff Wong 2020-12-10 07:06:41 -10:00 committed by GitHub
parent adda53c462
commit 4858ae0b19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -821,7 +821,7 @@ class StaffActionLogger
def params(opts = nil)
opts ||= {}
{ acting_user_id: @admin.id, context: opts[:context] }
{ acting_user_id: @admin.id, context: opts[:context], details: opts[:details] }
end
def validate_category(category)

View File

@ -80,7 +80,7 @@ class UserSilencer
def unsilence
@user.silenced_till = nil
if @user.save
DiscourseEvent.trigger(:user_unsilenced, user: @user)
DiscourseEvent.trigger(:user_unsilenced, user: @user, by_user: @by_user)
SystemMessage.create(@user, :unsilenced)
StaffActionLogger.new(@by_user).log_unsilence_user(@user) if @by_user
end