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:
Jeff Wong
2021-07-12 08:36:56 -10:00
committed by GitHub
parent 729a9856f8
commit d87a0216bb
13 changed files with 92 additions and 4 deletions

View File

@ -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