0
0
Fork 0

Use separate workers to process imports, retry failures (#5207)

This commit is contained in:
Eugen Rochko 2017-10-04 00:39:32 +02:00 committed by GitHub
parent c743b5e1fd
commit cdd5ef691b
2 changed files with 38 additions and 45 deletions

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
class Import::RelationshipWorker
include Sidekiq::Worker
sidekiq_options queue: 'pull', retry: 8, dead: false
def perform(account_id, target_account_uri, relationship)
from_account = Account.find(account_id)
target_account = ResolveRemoteAccountService.new.call(target_account_uri)
return if target_account.nil?
case relationship
when 'follow'
FollowService.new.call(from_account, target_account.acct)
when 'block'
BlockService.new.call(from_account, target_account)
when 'mute'
MuteService.new.call(from_account, target_account)
end
rescue ActiveRecord::RecordNotFound
true
end
end