Skip to content

Commit

Permalink
Deleting media attachments in status batch actions, too
Browse files Browse the repository at this point in the history
  • Loading branch information
nina-py committed Nov 30, 2023
1 parent 3111e59 commit 09bfd22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/models/admin/status_batch_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def handle_delete!
statuses.each do |status|
status.discard_with_reblogs
log_action(:destroy, status)

next unless status.with_media?

# Immediately remove public copy of media instead of waiting for
# the vacuum_orphaned_records job to take care of it later on
Admin::MediaAttachmentDeletionWorker.perform_inline(status.media_attachments)
end

if with_report?
Expand Down
1 change: 0 additions & 1 deletion app/workers/admin/media_attachment_deletion_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Admin::MediaAttachmentDeletionWorker
sidekiq_options queue: 'pull', lock: :until_executed, lock_ttl: 1.week.to_i

def perform(media_attachments)
# remove both attachments and associations between statuses and media
AttachmentBatch.new(MediaAttachment, media_attachments).clear
end
end

0 comments on commit 09bfd22

Please sign in to comment.