mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 01:36:27 +08:00
05b8ff436c
This will help to enforce a consistent pattern for creating service actions. This patch also namespaces actions and policies, making everything related to a service available directly in `app/services/<concept-name>`, making things more consistent at that level too.
24 lines
527 B
Ruby
24 lines
527 B
Ruby
# frozen_string_literal: true
|
|
|
|
class User::Policy::NotAlreadySuspended < Service::PolicyBase
|
|
delegate :user, to: :context, private: true
|
|
delegate :suspend_record, to: :user, private: true
|
|
|
|
def call
|
|
!user.suspended?
|
|
end
|
|
|
|
def reason
|
|
I18n.t(
|
|
"user.already_suspended",
|
|
staff: suspend_record.acting_user.username,
|
|
time_ago:
|
|
AgeWords.time_ago_in_words(
|
|
suspend_record.created_at,
|
|
true,
|
|
scope: :"datetime.distance_in_words_verbose",
|
|
),
|
|
)
|
|
end
|
|
end
|