diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-08-23 22:37:23 +0200 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2020-02-27 14:02:57 -0600 |
commit | 1213311562928551918495a69e4c6f87236f6a66 (patch) | |
tree | dc1274de8877beee411b9a72efccc66cd11603ab /app/models/admin | |
parent | 3681f7dcce8f82d2a4377a051952159cd03919c0 (diff) |
port tootsuite#11639 to monsterfork: Add option to include reported statuses in warning e-mail
Diffstat (limited to 'app/models/admin')
-rw-r--r-- | app/models/admin/account_action.rb | 25 |
1 files changed, 17 insertions, 8 deletions
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? |