Skip to content

Commit

Permalink
Merge commit '27e84c069112a3d2abfad947642457cc997a261a' into kb-merge…
Browse files Browse the repository at this point in the history
…-231010
  • Loading branch information
kmycode committed Oct 11, 2023
2 parents 80498c8 + 27e84c0 commit 54898d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/services/report_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def forward_to_origin!

def forward_to_replied_to!
# Send report to servers to which the account was replying to, so they also have a chance to act
inbox_urls = Account.remote.where(domain: forward_to_domains).where(id: Status.where(id: reported_status_ids).where.not(in_reply_to_account_id: nil).select(:in_reply_to_account_id)).inboxes - [@target_account.inbox_url]
inbox_urls = Account.remote.where(domain: forward_to_domains).where(id: Status.where(id: reported_status_ids).where.not(in_reply_to_account_id: nil).select(:in_reply_to_account_id)).inboxes - [@target_account.inbox_url, @target_account.shared_inbox_url]

inbox_urls.each do |inbox_url|
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
Expand Down
21 changes: 20 additions & 1 deletion spec/services/report_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
expect(report.uri).to_not be_nil
end

context 'when reporting a reply' do
context 'when reporting a reply on a different remote server' do
let(:remote_thread_account) { Fabricate(:account, domain: 'foo.com', protocol: :activitypub, inbox_url: 'http://foo.com/inbox') }
let(:reported_status) { Fabricate(:status, account: remote_account, thread: Fabricate(:status, account: remote_thread_account)) }

Expand Down Expand Up @@ -67,6 +67,25 @@
end
end
end

context 'when reporting a reply on the same remote server as the person being replied-to' do
let(:remote_thread_account) { Fabricate(:account, domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
let(:reported_status) { Fabricate(:status, account: remote_account, thread: Fabricate(:status, account: remote_thread_account)) }

context 'when forward_to_domains includes both the replied-to domain and the origin domain' do
it 'sends ActivityPub payload only once' do
subject.call(source_account, remote_account, status_ids: [reported_status.id], forward: forward, forward_to_domains: [remote_account.domain])
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end

context 'when forward_to_domains does not include the replied-to domain' do
it 'sends ActivityPub payload only once' do
subject.call(source_account, remote_account, status_ids: [reported_status.id], forward: forward)
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end
end
end

context 'when forward is false' do
Expand Down

0 comments on commit 54898d5

Please sign in to comment.