This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-10-03 15:39:32 -07:00
|
|
|
# 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)
|
2018-01-22 05:25:09 -08:00
|
|
|
target_account = ResolveAccountService.new.call(target_account_uri)
|
2017-10-03 15:39:32 -07:00
|
|
|
|
|
|
|
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
|