Fix duplicate reports being sent when reporting some remote posts (port to v4.2.1) (#27356)
parent
790fd1374f
commit
74dd325112
|
@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fix duplicate reports being sent when reporting some remote posts ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/27355))
|
||||||
- Fix clicking on already-opened thread post scrolling to the top of the thread ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/27331), [ClearlyClaire](https://github.com/mastodon/mastodon/pull/27338), [ClearlyClaire](https://github.com/mastodon/mastodon/pull/27350))
|
- Fix clicking on already-opened thread post scrolling to the top of the thread ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/27331), [ClearlyClaire](https://github.com/mastodon/mastodon/pull/27338), [ClearlyClaire](https://github.com/mastodon/mastodon/pull/27350))
|
||||||
- Fix some remote posts getting truncated ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/27307))
|
- Fix some remote posts getting truncated ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/27307))
|
||||||
- Fix some cases of infinite scroll code trying to fetch inaccessible posts in a loop ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/27286))
|
- Fix some cases of infinite scroll code trying to fetch inaccessible posts in a loop ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/27286))
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ReportService < BaseService
|
||||||
|
|
||||||
def forward_to_replied_to!
|
def forward_to_replied_to!
|
||||||
# Send report to servers to which the account was replying to, so they also have a chance to act
|
# 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|
|
inbox_urls.each do |inbox_url|
|
||||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||||
|
|
|
@ -36,7 +36,7 @@ RSpec.describe ReportService, type: :service do
|
||||||
expect(report.uri).to_not be_nil
|
expect(report.uri).to_not be_nil
|
||||||
end
|
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(: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)) }
|
let(:reported_status) { Fabricate(:status, account: remote_account, thread: Fabricate(:status, account: remote_thread_account)) }
|
||||||
|
|
||||||
|
@ -67,6 +67,25 @@ RSpec.describe ReportService, type: :service do
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'when forward is false' do
|
context 'when forward is false' do
|
||||||
|
|
Reference in New Issue