about summary refs log tree commit diff
path: root/app/models/admin/status_batch_action.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-02-11 21:51:57 +0100
committerGitHub <noreply@github.com>2022-02-11 21:51:57 +0100
commitd0fcf07436d158bcac2617d076a83d0aa49c39e6 (patch)
tree4a1c3737e029ad9bb9f976c15e3e66d86dfca47f /app/models/admin/status_batch_action.rb
parenta27729ee48aab4d75d562c2007b9967333c65d29 (diff)
Change actions in reports to require only one click (#17487)
Diffstat (limited to 'app/models/admin/status_batch_action.rb')
-rw-r--r--app/models/admin/status_batch_action.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/admin/status_batch_action.rb b/app/models/admin/status_batch_action.rb
index 85822214b..40f60f379 100644
--- a/app/models/admin/status_batch_action.rb
+++ b/app/models/admin/status_batch_action.rb
@@ -8,6 +8,12 @@ class Admin::StatusBatchAction
   attr_accessor :current_account, :type,
                 :status_ids, :report_id
 
+  attr_reader :send_email_notification
+
+  def send_email_notification=(value)
+    @send_email_notification = ActiveModel::Type::Boolean.new.cast(value)
+  end
+
   def save!
     process_action!
   end
@@ -55,7 +61,7 @@ class Admin::StatusBatchAction
       statuses.each { |status| Tombstone.find_or_create_by(uri: status.uri, account: status.account, by_moderator: true) } unless target_account.local?
     end
 
-    UserMailer.warning(target_account.user, @warning).deliver_later! if target_account.local?
+    UserMailer.warning(target_account.user, @warning).deliver_later! if warnable?
     RemovalWorker.push_bulk(status_ids) { |status_id| [status_id, { 'preserve' => target_account.local?, 'immediate' => !target_account.local? }] }
   end
 
@@ -82,6 +88,10 @@ class Admin::StatusBatchAction
     !report.nil?
   end
 
+  def warnable?
+    send_email_notification && target_account.local?
+  end
+
   def target_account
     @target_account ||= statuses.first.account
   end