1 # frozen_string_literal: true
3 class Form
::StatusBatch
4 include ActiveModel
::Model
5 include AccountableConcern
7 attr_accessor
:status_ids, :action, :current_account
11 when 'nsfw_on', 'nsfw_off'
12 change_sensitive(action
== 'nsfw_on')
20 def change_sensitive(sensitive
)
21 media_attached_status_ids
= MediaAttachment
.where(status_id
: status_ids
).pluck(:status_id)
23 ApplicationRecord
.transaction
do
24 Status
.where(id
: media_attached_status_ids
).reorder(nil).find_each
do |status
|
25 status
.update!
(sensitive
: sensitive
)
26 log_action
:update, status
31 rescue ActiveRecord
::RecordInvalid
36 Status
.where(id
: status_ids
).reorder(nil).find_each
do |status
|
37 RemovalWorker
.perform_async(status
.id
)
38 log_action
:destroy, status