This repository has been archived by the owner on Feb 24, 2025. It is now read-only.
forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from MozillaSocial/SOCIALPLAT-766-immediately-…
…remove-public-copy-of-media feat(trust & safety): [SOCIALPLAT-766] Immediately remove public copy of media when status is deleted - Set up a new MediaAttachmentDeletionWorker to delete media. - Add unit tests for MediaAttachmentDeletionWorker. - Use the new worker in the two spots it's needed in status controllers. - Update unit tests for status controllers to check for media deletion. JIRA reference: https://mozilla-hub.atlassian.net/browse/SOCTRUST-31
Showing
5 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class Admin::MediaAttachmentDeletionWorker | ||
include Sidekiq::Worker | ||
|
||
sidekiq_options queue: 'pull', lock: :until_executed, lock_ttl: 1.week.to_i | ||
|
||
def perform(media_attachments) | ||
AttachmentBatch.new(MediaAttachment, media_attachments).clear | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
spec/workers/admin/media_attachment_deletion_worker_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe Admin::MediaAttachmentDeletionWorker do | ||
let(:worker) { described_class.new } | ||
let(:local_status) { Fabricate(:status) } | ||
let(:remote_status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com')) } | ||
|
||
describe 'perform' do | ||
let!(:remote_media) { Fabricate(:media_attachment, remote_url: 'https://example.com/foo.png', status: remote_status) } | ||
let!(:local_media) { Fabricate(:media_attachment, status: local_status) } | ||
|
||
it 'deletes remote media attachments' do | ||
subject.perform([remote_media]) | ||
expect(remote_media.reload.file).to be_blank | ||
end | ||
|
||
it 'deletes local media attachments' do | ||
subject.perform([local_media]) | ||
expect(local_media.reload.file).to be_blank | ||
end | ||
end | ||
end |