Change relays handling to not record boosts (#17571)
* Change relays handling to not record boosts * Update testsmain
parent
73fce8d311
commit
8f537a1168
|
@ -8,6 +8,7 @@ class ActivityPub::Activity::Announce < ActivityPub::Activity
|
||||||
original_status = status_from_object
|
original_status = status_from_object
|
||||||
|
|
||||||
return reject_payload! if original_status.nil? || !announceable?(original_status)
|
return reject_payload! if original_status.nil? || !announceable?(original_status)
|
||||||
|
return if requested_through_relay?
|
||||||
|
|
||||||
@status = Status.find_by(account: @account, reblog: original_status)
|
@status = Status.find_by(account: @account, reblog: original_status)
|
||||||
|
|
||||||
|
|
|
@ -113,26 +113,23 @@ RSpec.describe ActivityPub::Activity::Announce do
|
||||||
let!(:relay_account) { Fabricate(:account, inbox_url: 'https://relay.example.com/inbox') }
|
let!(:relay_account) { Fabricate(:account, inbox_url: 'https://relay.example.com/inbox') }
|
||||||
let!(:relay) { Fabricate(:relay, inbox_url: 'https://relay.example.com/inbox') }
|
let!(:relay) { Fabricate(:relay, inbox_url: 'https://relay.example.com/inbox') }
|
||||||
|
|
||||||
|
let(:object_json) { 'https://example.com/actor/hello-world' }
|
||||||
|
|
||||||
subject { described_class.new(json, sender, relayed_through_account: relay_account) }
|
subject { described_class.new(json, sender, relayed_through_account: relay_account) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json))
|
||||||
|
end
|
||||||
|
|
||||||
context 'and the relay is enabled' do
|
context 'and the relay is enabled' do
|
||||||
before do
|
before do
|
||||||
relay.update(state: :accepted)
|
relay.update(state: :accepted)
|
||||||
subject.perform
|
subject.perform
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:object_json) do
|
it 'fetches the remote status' do
|
||||||
{
|
expect(a_request(:get, 'https://example.com/actor/hello-world')).to have_been_made
|
||||||
id: 'https://example.com/actor#bar',
|
expect(Status.find_by(uri: 'https://example.com/actor/hello-world').text).to eq 'Hello world'
|
||||||
type: 'Note',
|
|
||||||
content: 'Lorem ipsum',
|
|
||||||
to: 'http://example.com/followers',
|
|
||||||
attributedTo: 'https://example.com/actor',
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates a reblog by sender of status' do
|
|
||||||
expect(sender.statuses.count).to eq 2
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,14 +138,9 @@ RSpec.describe ActivityPub::Activity::Announce do
|
||||||
subject.perform
|
subject.perform
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:object_json) do
|
it 'does not fetch the remote status' do
|
||||||
{
|
expect(a_request(:get, 'https://example.com/actor/hello-world')).not_to have_been_made
|
||||||
id: 'https://example.com/actor#bar',
|
expect(Status.find_by(uri: 'https://example.com/actor/hello-world')).to be_nil
|
||||||
type: 'Note',
|
|
||||||
content: 'Lorem ipsum',
|
|
||||||
to: 'http://example.com/followers',
|
|
||||||
attributedTo: 'https://example.com/actor',
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create anything' do
|
it 'does not create anything' do
|
||||||
|
|
Loading…
Reference in New Issue