Fix Announce activities of unknown statuses not fetching those statuses (#10065)
Regression from #9998
This commit is contained in:
parent
71b831601d
commit
b163368c3e
@ -150,8 +150,7 @@ class ActivityPub::Activity
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# If the status is not from the actor, try to fetch it
|
fetch_remote_original_status
|
||||||
return fetch_remote_original_status if value_or_id(first_of_value(@json['attributedTo'])) == @account.uri
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_remote_original_status
|
def fetch_remote_original_status
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::Activity::Announce do
|
RSpec.describe ActivityPub::Activity::Announce do
|
||||||
let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers') }
|
let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers', uri: 'https://example.com/actor') }
|
||||||
let(:recipient) { Fabricate(:account) }
|
let(:recipient) { Fabricate(:account) }
|
||||||
let(:status) { Fabricate(:status, account: recipient) }
|
let(:status) { Fabricate(:status, account: recipient) }
|
||||||
|
|
||||||
@ -10,21 +10,29 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: 'foo',
|
id: 'foo',
|
||||||
type: 'Announce',
|
type: 'Announce',
|
||||||
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
actor: 'https://example.com/actor',
|
||||||
object: object_json,
|
object: object_json,
|
||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.new(json, sender) }
|
let(:unknown_object_json) do
|
||||||
|
{
|
||||||
before do
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender))
|
id: 'https://example.com/actor/hello-world',
|
||||||
|
type: 'Note',
|
||||||
|
attributedTo: 'https://example.com/actor',
|
||||||
|
content: 'Hello world',
|
||||||
|
to: 'http://example.com/followers',
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
subject { described_class.new(json, sender) }
|
||||||
|
|
||||||
describe '#perform' do
|
describe '#perform' do
|
||||||
context 'when sender is followed by a local account' do
|
context 'when sender is followed by a local account' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:account).follow!(sender)
|
Fabricate(:account).follow!(sender)
|
||||||
|
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json))
|
||||||
subject.perform
|
subject.perform
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -38,10 +46,21 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'an unknown status' do
|
||||||
|
let(:object_json) { 'https://example.com/actor/hello-world' }
|
||||||
|
|
||||||
|
it 'creates a reblog by sender of status' do
|
||||||
|
reblog = sender.statuses.first
|
||||||
|
|
||||||
|
expect(reblog).to_not be_nil
|
||||||
|
expect(reblog.reblog.text).to eq 'Hello world'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'self-boost of a previously unknown status with missing attributedTo' do
|
context 'self-boost of a previously unknown status with missing attributedTo' do
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
id: 'https://example.com/actor#bar',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
to: 'http://example.com/followers',
|
to: 'http://example.com/followers',
|
||||||
@ -56,10 +75,10 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||||||
context 'self-boost of a previously unknown status with correct attributedTo' do
|
context 'self-boost of a previously unknown status with correct attributedTo' do
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
id: 'https://example.com/actor#bar',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
attributedTo: 'https://example.com/actor',
|
||||||
to: 'http://example.com/followers',
|
to: 'http://example.com/followers',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -98,7 +117,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||||||
|
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
id: 'https://example.com/actor#bar',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
to: 'http://example.com/followers',
|
to: 'http://example.com/followers',
|
||||||
@ -117,7 +136,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||||||
|
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
id: 'https://example.com/actor#bar',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
to: 'http://example.com/followers',
|
to: 'http://example.com/followers',
|
||||||
@ -137,7 +156,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||||||
|
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
id: 'https://example.com/actor#bar',
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
content: 'Lorem ipsum',
|
content: 'Lorem ipsum',
|
||||||
to: 'http://example.com/followers',
|
to: 'http://example.com/followers',
|
||||||
|
Loading…
Reference in New Issue
Block a user