|
|
|
@ -20,18 +20,18 @@ class Admin::AccountAction
|
|
|
|
|
:report_id,
|
|
|
|
|
:warning_preset_id
|
|
|
|
|
|
|
|
|
|
attr_reader :warning, :send_email_notification, :send_in_app_notification, :include_statuses
|
|
|
|
|
attr_reader :warning, :send_notification, :send_email_notification, :include_statuses
|
|
|
|
|
|
|
|
|
|
alias send_notification? send_notification
|
|
|
|
|
alias send_email_notification? send_email_notification
|
|
|
|
|
alias send_in_app_notification? send_in_app_notification
|
|
|
|
|
alias include_statuses? include_statuses
|
|
|
|
|
|
|
|
|
|
validates :type, :target_account, :current_account, presence: true
|
|
|
|
|
validates :type, inclusion: { in: TYPES }
|
|
|
|
|
|
|
|
|
|
def initialize(attributes = {})
|
|
|
|
|
@send_notification = true
|
|
|
|
|
@send_email_notification = true
|
|
|
|
|
@send_in_app_notification = true
|
|
|
|
|
@include_statuses = true
|
|
|
|
|
|
|
|
|
|
super
|
|
|
|
@ -41,8 +41,8 @@ class Admin::AccountAction
|
|
|
|
|
@send_email_notification = ActiveModel::Type::Boolean.new.cast(value)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def send_in_app_notification=(value)
|
|
|
|
|
@send_in_app_notification = ActiveModel::Type::Boolean.new.cast(value)
|
|
|
|
|
def send_notification=(value)
|
|
|
|
|
@send_notification = ActiveModel::Type::Boolean.new.cast(value)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def include_statuses=(value)
|
|
|
|
@ -173,10 +173,14 @@ class Admin::AccountAction
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def process_notification!
|
|
|
|
|
return unless target_account.local?
|
|
|
|
|
return unless warnable?
|
|
|
|
|
|
|
|
|
|
UserMailer.warning(target_account.user, warning).deliver_later! if send_email_notification?
|
|
|
|
|
LocalNotificationWorker.perform_async(target_account.id, warning.id, 'AccountWarning', 'moderation_warning') if send_in_app_notification?
|
|
|
|
|
LocalNotificationWorker.perform_async(target_account.id, warning.id, 'AccountWarning', 'moderation_warning')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def warnable?
|
|
|
|
|
send_notification && target_account.local?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def status_ids
|
|
|
|
|