blob: 936593166604a442b1525b2a350e06555835f153 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# frozen_string_literal: true
class ActivityPub::ProcessCollectionItemsService < BaseService
def call(account_id, on_behalf_of)
RedisLock.acquire(lock_options(account_id)) do |lock|
if lock.acquired?
CollectionItem.unprocessed.where(account_id: account_id).find_each do |item|
begin
FetchRemoteStatusService.new.call(item.uri, nil, on_behalf_of)
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotFound
nil
end
item.update!(processed: true)
end
end
end
end
private
def lock_options(account_id)
{ redis: Redis.current, key: "process_collection_items:#{account_id}" }
end
end
|