Skip to content

Commit

Permalink
Handle featured collections without items (mastodon#27581)
Browse files Browse the repository at this point in the history
  • Loading branch information
tribela authored Oct 27, 2023
1 parent fa7e64d commit 8f998cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/services/activitypub/fetch_featured_collection_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def fetch_collection(collection_or_uri)
end

def process_items(items)
return if items.nil?

process_note_items(items) if @options[:note]
process_hashtag_items(items) if @options[:hashtag]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,22 @@
}
end

let(:featured_with_null) do
{
'@context': 'https://www.w3.org/ns/activitystreams',
id: 'https://example.com/account/collections/featured',
totalItems: 0,
type: 'OrderedCollection',
}
end

let(:items) do
[
'https://example.com/account/pinned/known', # known
status_json_pinned_unknown_inlined, # unknown inlined
'https://example.com/account/pinned/unknown-unreachable', # unknown unreachable
'https://example.com/account/pinned/unknown-reachable', # unknown reachable
'https://example.com/account/collections/featured', # featured with null
]
end

Expand All @@ -66,6 +76,7 @@
stub_request(:get, 'https://example.com/account/pinned/unknown-inlined').to_return(status: 200, body: Oj.dump(status_json_pinned_unknown_inlined))
stub_request(:get, 'https://example.com/account/pinned/unknown-unreachable').to_return(status: 404)
stub_request(:get, 'https://example.com/account/pinned/unknown-reachable').to_return(status: 200, body: Oj.dump(status_json_pinned_unknown_unreachable))
stub_request(:get, 'https://example.com/account/collections/featured').to_return(status: 200, body: Oj.dump(featured_with_null))

subject.call(actor, note: true, hashtag: false)
end
Expand Down

0 comments on commit 8f998cd

Please sign in to comment.