mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 13:07:54 +08:00
FEATURE: Penalty history improvements (#13359)
* FEATURE: add penalty history when silencing a user Display penalty history (last 6 months) when silencing/suspending a user * FEATURE: allow default penalty values to be chosen Adds a site setting that designates default penalty values in hours. Silence/suspend modals will auto-fill in the default values, but otherwise will still allow moderators to pick and overwrite values as normal. First silence/suspend: first value Second silence/suspend: second value etc. Penalty counts are forgiven at the same rate as tl3 promotion requirements do. Co-authored-by: jjaffeux <j.jaffeux@gmail.com>
This commit is contained in:
@ -22,6 +22,8 @@ class AdminDetailedUserSerializer < AdminUserSerializer
|
||||
:full_suspend_reason,
|
||||
:suspended_till,
|
||||
:silence_reason,
|
||||
:penalty_counts,
|
||||
:next_penalty,
|
||||
:primary_group_id,
|
||||
:badge_count,
|
||||
:warnings_received_count,
|
||||
@ -96,6 +98,20 @@ class AdminDetailedUserSerializer < AdminUserSerializer
|
||||
object.silence_reason
|
||||
end
|
||||
|
||||
def penalty_counts
|
||||
TrustLevel3Requirements.new(object).penalty_counts
|
||||
end
|
||||
|
||||
def next_penalty
|
||||
step_number = penalty_counts.total
|
||||
steps = SiteSetting.penalty_step_hours.split('|')
|
||||
step_number = [step_number, steps.length].min
|
||||
penalty_hours = steps[step_number]
|
||||
Integer(penalty_hours, 10).hours.from_now
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
def silenced_by
|
||||
object.silenced_record.try(:acting_user)
|
||||
end
|
||||
|
Reference in New Issue
Block a user