UX: suspend forever time period messages (#13776)

When the Forever option is selected for suspending a user, the user is suspended for 1000 years. Without customizing the site’s text, this time period is displayed to the user in the suspension email that is sent to the user, and if the user attempts to log back into the site. Telling someone that they have been suspended for 1000 years seems likely to come across as a bad attempt at humour.

This PR special case messages when a user suspended or silenced forever.
This commit is contained in:
Andrei Prigorshnev
2021-07-20 14:42:08 +04:00
committed by GitHub
parent 351ef6c2cc
commit 1a8c949900
6 changed files with 94 additions and 26 deletions

View File

@ -958,6 +958,10 @@ class User < ActiveRecord::Base
silenced_record.try(:created_at) if silenced?
end
def silenced_forever?
silenced_till > 100.years.from_now
end
def suspend_record
UserHistory.for(self, :suspend_user).order('id DESC').first
end
@ -974,6 +978,27 @@ class User < ActiveRecord::Base
nil
end
def suspended_message
return nil unless suspended?
message = "login.suspended"
if suspend_reason
if suspended_forever?
message = "login.suspended_with_reason_forever"
else
message = "login.suspended_with_reason"
end
end
I18n.t(message,
date: I18n.l(suspended_till, format: :date_only),
reason: Rack::Utils.escape_html(suspend_reason))
end
def suspended_forever?
suspended_till > 100.years.from_now
end
# Use this helper to determine if the user has a particular trust level.
# Takes into account admin, etc.
def has_trust_level?(level)