about summary refs log tree commit diff
path: root/app/workers/import/relationship_worker.rb
blob: ed4c962c19f57e0a51b4dfe64f0577fb5a6bdd9b (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
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