From a0f6b6d36521723078399953a5451cbbd24c99a1 Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Wed, 25 Mar 2026 15:29:11 +0100 Subject: [PATCH] Fix off-by-one error when creating collection items (#38394) --- .../activitypub/process_featured_collection_service.rb | 2 +- .../activitypub/process_featured_collection_service_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/activitypub/process_featured_collection_service.rb b/app/services/activitypub/process_featured_collection_service.rb index 2ef555e6bc..80742b081e 100644 --- a/app/services/activitypub/process_featured_collection_service.rb +++ b/app/services/activitypub/process_featured_collection_service.rb @@ -51,7 +51,7 @@ class ActivityPub::ProcessFeaturedCollectionService items = @json['orderedItems'] || [] items.take(ITEMS_LIMIT).each_with_index do |item_json, index| uris << value_or_id(item_json) - ActivityPub::ProcessFeaturedItemWorker.perform_async(@collection.id, item_json, index, @request_id) + ActivityPub::ProcessFeaturedItemWorker.perform_async(@collection.id, item_json, index + 1, @request_id) end uris.compact! @collection.collection_items.where.not(uri: uris).delete_all diff --git a/spec/services/activitypub/process_featured_collection_service_spec.rb b/spec/services/activitypub/process_featured_collection_service_spec.rb index c68120bf0d..343d3ac3b2 100644 --- a/spec/services/activitypub/process_featured_collection_service_spec.rb +++ b/spec/services/activitypub/process_featured_collection_service_spec.rb @@ -52,7 +52,8 @@ RSpec.describe ActivityPub::ProcessFeaturedCollectionService do expect(new_collection.discoverable).to be true expect(new_collection.tag.formatted_name).to eq '#people' - expect(ActivityPub::ProcessFeaturedItemWorker).to have_enqueued_sidekiq_job.exactly(2).times + expect(ActivityPub::ProcessFeaturedItemWorker).to have_enqueued_sidekiq_job.with(new_collection.id, 'https://example.com/featured_items/1', 1, nil) + expect(ActivityPub::ProcessFeaturedItemWorker).to have_enqueued_sidekiq_job.with(new_collection.id, 'https://example.com/featured_items/2', 2, nil) end end