summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeong Arm <kjwonmail@gmail.com>2023-10-27 11:36:22 +0900
committerGitHub <noreply@github.com>2023-10-27 02:36:22 +0000
commit8f998cd96a1512b545cf674edad012839cec5cb2 (patch)
tree5819e33be827b27c41e6a3a47c9ecdf660a6261d
parentfa7e64df1de13b361551b0ff8f81335719c1a4a2 (diff)
Handle featured collections without items (#27581)
-rw-r--r--app/services/activitypub/fetch_featured_collection_service.rb2
-rw-r--r--spec/services/activitypub/fetch_featured_collection_service_spec.rb11
2 files changed, 13 insertions, 0 deletions
diff --git a/app/services/activitypub/fetch_featured_collection_service.rb b/app/services/activitypub/fetch_featured_collection_service.rb
index e8a31dade9b..d2bae08a0e4 100644
--- a/app/services/activitypub/fetch_featured_collection_service.rb
+++ b/app/services/activitypub/fetch_featured_collection_service.rb
@@ -37,6 +37,8 @@ class ActivityPub::FetchFeaturedCollectionService < BaseService
end
def process_items(items)
+ return if items.nil?
+
process_note_items(items) if @options[:note]
process_hashtag_items(items) if @options[:hashtag]
end
diff --git a/spec/services/activitypub/fetch_featured_collection_service_spec.rb b/spec/services/activitypub/fetch_featured_collection_service_spec.rb
index 5975c81a101..466da891a8b 100644
--- a/spec/services/activitypub/fetch_featured_collection_service_spec.rb
+++ b/spec/services/activitypub/fetch_featured_collection_service_spec.rb
@@ -42,12 +42,22 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do
}
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
@@ -66,6 +76,7 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do
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