Browse Source
It figures a new release would come out immediately after we release 1.2.0 😅 This is a minor bugfix release though, and was very easy to cherry-pick in. https://github.com/mastodon/mastodon/releases/tag/v4.5.7 cc @dariusk --------- Co-authored-by: David Roetzel <david@roetzel.de> Co-authored-by: Claire <claire.github-309c@sitedethib.com> Co-authored-by: ChaosExAnima <ChaosExAnima@users.noreply.github.com> Co-authored-by: Matt Jankowski <matt@jankowski.online>hometown-dev
33 changed files with 273 additions and 91 deletions
@ -0,0 +1,15 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class PurgeCustomEmojiWorker |
||||||
|
include Sidekiq::IterableJob |
||||||
|
|
||||||
|
def build_enumerator(domain, cursor:) |
||||||
|
return if domain.blank? |
||||||
|
|
||||||
|
active_record_batches_enumerator(CustomEmoji.by_domain_and_subdomains(domain), cursor:) |
||||||
|
end |
||||||
|
|
||||||
|
def each_iteration(custom_emojis, _domain) |
||||||
|
AttachmentBatch.new(CustomEmoji, custom_emojis).delete |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
RSpec.shared_examples 'forbidden for unconfirmed provider' do |
||||||
|
context 'when the requesting provider is unconfirmed' do |
||||||
|
let(:provider) { Fabricate(:fasp_provider) } |
||||||
|
|
||||||
|
it 'returns http unauthorized' do |
||||||
|
subject |
||||||
|
|
||||||
|
expect(response).to have_http_status(401) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
require 'rails_helper' |
||||||
|
|
||||||
|
RSpec.describe PurgeCustomEmojiWorker do |
||||||
|
let(:worker) { described_class.new } |
||||||
|
|
||||||
|
let(:domain) { 'evil' } |
||||||
|
|
||||||
|
before do |
||||||
|
Fabricate(:custom_emoji) |
||||||
|
Fabricate(:custom_emoji, domain: 'example.com') |
||||||
|
Fabricate.times(5, :custom_emoji, domain: domain) |
||||||
|
end |
||||||
|
|
||||||
|
describe '#perform' do |
||||||
|
context 'when domain is nil' do |
||||||
|
it 'does not delete emojis' do |
||||||
|
expect { worker.perform(nil) } |
||||||
|
.to_not(change(CustomEmoji, :count)) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context 'when passing a domain' do |
||||||
|
it 'deletes emojis from this domain only' do |
||||||
|
expect { worker.perform(domain) } |
||||||
|
.to change { CustomEmoji.where(domain: domain).count }.to(0) |
||||||
|
.and not_change { CustomEmoji.local.count } |
||||||
|
.and(not_change { CustomEmoji.where(domain: 'example.com').count }) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
Loading…
Reference in new issue