diff options
Diffstat (limited to 'app/services/activitypub/process_collection_items_service.rb')
-rw-r--r-- | app/services/activitypub/process_collection_items_service.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/activitypub/process_collection_items_service.rb b/app/services/activitypub/process_collection_items_service.rb index 936593166..9c30d81e9 100644 --- a/app/services/activitypub/process_collection_items_service.rb +++ b/app/services/activitypub/process_collection_items_service.rb @@ -5,12 +5,18 @@ class ActivityPub::ProcessCollectionItemsService < BaseService RedisLock.acquire(lock_options(account_id)) do |lock| if lock.acquired? CollectionItem.unprocessed.where(account_id: account_id).find_each do |item| + # Avoid failing servers holding up the rest of the queue. + next if item.retries.positive? && rand(3).positive? + begin FetchRemoteStatusService.new.call(item.uri, nil, on_behalf_of) rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotFound nil + rescue HTTP::TimeoutError + item.increment!(:retries) end - item.update!(processed: true) + + item.update!(processed: true) if item.retries.zero? || item.retries > 4 end end end |