Fix crash when likes
or shares
collections are not inlined, for real (#34619)
This commit is contained in:
parent
41d00bc28b
commit
22e2e7f02b
2 changed files with 20 additions and 2 deletions
|
@ -95,11 +95,11 @@ class ActivityPub::Parser::StatusParser
|
||||||
end
|
end
|
||||||
|
|
||||||
def favourites_count
|
def favourites_count
|
||||||
@object.dig('likes', 'totalItems') if @object.is_a?(Hash)
|
@object['likes']['totalItems'] if @object.is_a?(Hash) && @object['likes'].is_a?(Hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reblogs_count
|
def reblogs_count
|
||||||
@object.dig('shares', 'totalItems') if @object.is_a?(Hash)
|
@object['shares']['totalItems'] if @object.is_a?(Hash) && @object['shares'].is_a?(Hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
def quote_policy
|
def quote_policy
|
||||||
|
|
|
@ -49,6 +49,24 @@ RSpec.describe ActivityPub::Parser::StatusParser do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the likes collection is not inlined' do
|
||||||
|
let(:object_json) do
|
||||||
|
{
|
||||||
|
id: [ActivityPub::TagManager.instance.uri_for(sender), 'post1'].join('/'),
|
||||||
|
type: 'Note',
|
||||||
|
to: 'https://www.w3.org/ns/activitystreams#Public',
|
||||||
|
content: 'bleh',
|
||||||
|
published: 1.hour.ago.utc.iso8601,
|
||||||
|
updated: 1.hour.ago.utc.iso8601,
|
||||||
|
likes: 'https://example.com/collections/likes',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not raise an error' do
|
||||||
|
expect { subject.favourites_count }.to_not raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#quote_policy' do
|
describe '#quote_policy' do
|
||||||
subject do
|
subject do
|
||||||
described_class
|
described_class
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue