Skip to content

Commit

Permalink
Do not misattribute inlined boosts if attributedTo isn't present (m…
Browse files Browse the repository at this point in the history
…astodon#10967)

* Do not misattribute inlined boosts if `attributedTo` isn't present

Fixes mastodon#10950

* Fix tests
  • Loading branch information
ClearlyClaire authored and multiple creatures committed Nov 19, 2019
1 parent 3873a9e commit 61d29f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/lib/activitypub/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def status_from_object(announced_by: nil)

# If the boosted toot is embedded and it is a self-boost, handle it like a Create
unless unsupported_object_type?
actor_id = value_or_id(first_of_value(@object['attributedTo'])) || @account.uri
actor_id = value_or_id(first_of_value(@object['attributedTo']))

if actor_id == @account.uri
return ActivityPub::Activity.factory({ 'type' => 'Create', 'actor' => actor_id, 'object' => @object }, @account, announced_by: announced_by).perform
Expand Down
18 changes: 3 additions & 15 deletions spec/lib/activitypub/activity/announce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,6 @@
end
end

context 'self-boost of a previously unknown status with missing attributedTo' do
let(:object_json) do
{
id: 'https://example.com/actor#bar',
type: 'Note',
content: 'Lorem ipsum',
to: 'http://example.com/followers',
}
end

it 'creates a reblog by sender of status' do
expect(sender.reblogged?(sender.statuses.first)).to be true
end
end

context 'self-boost of a previously unknown status with correct attributedTo' do
let(:object_json) do
{
Expand Down Expand Up @@ -122,6 +107,7 @@
type: 'Note',
content: 'Lorem ipsum',
to: 'http://example.com/followers',
attributedTo: 'https://example.com/actor',
}
end

Expand All @@ -141,6 +127,7 @@
type: 'Note',
content: 'Lorem ipsum',
to: 'http://example.com/followers',
attributedTo: 'https://example.com/actor',
}
end

Expand All @@ -161,6 +148,7 @@
type: 'Note',
content: 'Lorem ipsum',
to: 'http://example.com/followers',
attributedTo: 'https://example.com/actor',
}
end

Expand Down

0 comments on commit 61d29f5

Please sign in to comment.