0
0
Fork 0

Add notifications of severed relationships (#27511)

This commit is contained in:
Claire 2024-03-20 16:37:21 +01:00 committed by GitHub
parent 8a1423a474
commit 44bf7b8128
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 781 additions and 54 deletions

View file

@ -5,22 +5,33 @@ require 'rails_helper'
RSpec.describe AfterBlockDomainFromAccountService do
subject { described_class.new }
let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/inbox', protocol: :activitypub) }
let!(:alice) { Fabricate(:account, username: 'alice') }
let(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/wolf/inbox', protocol: :activitypub) }
let(:dog) { Fabricate(:account, username: 'dog', domain: 'evil.org', inbox_url: 'https://evil.org/dog/inbox', protocol: :activitypub) }
let(:alice) { Fabricate(:account, username: 'alice') }
before do
allow(ActivityPub::DeliveryWorker).to receive(:perform_async)
wolf.follow!(alice)
alice.follow!(dog)
end
it 'purge followers from blocked domain' do
wolf.follow!(alice)
around do |example|
Sidekiq::Testing.fake! do
example.run
end
end
it 'purges followers from blocked domain, sends them Reject->Follow, and records severed relationships', :aggregate_failures do
subject.call(alice, 'evil.org')
expect(wolf.following?(alice)).to be false
end
expect(ActivityPub::DeliveryWorker.jobs.pluck('args')).to contain_exactly(
[a_string_including('"type":"Reject"'), alice.id, wolf.inbox_url],
[a_string_including('"type":"Undo"'), alice.id, dog.inbox_url]
)
it 'sends Reject->Follow to followers from blocked domain' do
wolf.follow!(alice)
subject.call(alice, 'evil.org')
expect(ActivityPub::DeliveryWorker).to have_received(:perform_async).once
severed_relationships = alice.severed_relationships.to_a
expect(severed_relationships.count).to eq 2
expect(severed_relationships[0].relationship_severance_event).to eq severed_relationships[1].relationship_severance_event
expect(severed_relationships.map { |rel| [rel.account, rel.target_account] }).to contain_exactly([wolf, alice], [alice, dog])
end
end