about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/lib/activitypub/activity/add.rb2
-rw-r--r--app/models/collection_item.rb1
-rw-r--r--app/services/activitypub/fetch_featured_collection_service.rb2
-rw-r--r--app/services/activitypub/process_collection_items_service.rb8
4 files changed, 10 insertions, 3 deletions
diff --git a/app/lib/activitypub/activity/add.rb b/app/lib/activitypub/activity/add.rb
index 688ab00b3..03b584302 100644
--- a/app/lib/activitypub/activity/add.rb
+++ b/app/lib/activitypub/activity/add.rb
@@ -9,6 +9,6 @@ class ActivityPub::Activity::Add < ActivityPub::Activity
 
     return unless !status.nil? && status.account_id == @account.id && !@account.pinned?(status)
 
-    StatusPin.create!(account: @account, status: status)
+    StatusPin.create(account: @account, status: status)
   end
 end
diff --git a/app/models/collection_item.rb b/app/models/collection_item.rb
index cecb86534..24aaf66d4 100644
--- a/app/models/collection_item.rb
+++ b/app/models/collection_item.rb
@@ -7,6 +7,7 @@
 #  account_id :bigint(8)
 #  uri        :string           not null
 #  processed  :boolean          default(FALSE), not null
+#  retries    :integer          default(0), not null
 #
 
 class CollectionItem < ApplicationRecord
diff --git a/app/services/activitypub/fetch_featured_collection_service.rb b/app/services/activitypub/fetch_featured_collection_service.rb
index a77c03bed..0a20f5edc 100644
--- a/app/services/activitypub/fetch_featured_collection_service.rb
+++ b/app/services/activitypub/fetch_featured_collection_service.rb
@@ -44,7 +44,7 @@ class ActivityPub::FetchFeaturedCollectionService < BaseService
     StatusPin.where(account: @account, status_id: to_remove).delete_all unless to_remove.empty?
 
     to_add.each do |status_id|
-      StatusPin.create!(account: @account, status_id: status_id)
+      StatusPin.create(account: @account, status_id: status_id)
     end
   end
 
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