From 1213311562928551918495a69e4c6f87236f6a66 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 23 Aug 2019 22:37:23 +0200 Subject: port tootsuite#11639 to monsterfork: Add option to include reported statuses in warning e-mail --- app/models/admin/account_action.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'app/models') diff --git a/app/models/admin/account_action.rb b/app/models/admin/account_action.rb index 173e4620b..00f50f6cd 100644 --- a/app/models/admin/account_action.rb +++ b/app/models/admin/account_action.rb @@ -21,10 +21,17 @@ class Admin::AccountAction :type, :text, :report_id, - :warning_preset_id, - :send_email_notification + :warning_preset_id - attr_reader :warning + attr_reader :warning, :send_email_notification, :include_statuses + + def send_email_notification=(value) + @send_email_notification = ActiveModel::Type::Boolean.new.cast(value) + end + + def include_statuses=(value) + @include_statuses = ActiveModel::Type::Boolean.new.cast(value) + end def save! ApplicationRecord.transaction do @@ -32,8 +39,9 @@ class Admin::AccountAction process_warning! end - queue_email! + process_email! process_reports! + process_queue! end def report @@ -135,7 +143,6 @@ class Admin::AccountAction authorize(target_account, :suspend?) log_action(:suspend, target_account) target_account.suspend! - queue_suspension_worker! end def handle_mark_unknown! @@ -158,10 +165,12 @@ class Admin::AccountAction Admin::SuspensionWorker.perform_async(target_account.id) end - def queue_email! - return unless warnable? + def process_queue! + queue_suspension_worker! if type == 'suspend' + end - UserMailer.warning(target_account.user, warning).deliver_later! + def process_email! + UserMailer.warning(target_account.user, warning, status_ids).deliver_now! if warnable? end def warnable? -- cgit