闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
684 B

  1. # frozen_string_literal: true
  2. class Import::RelationshipWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'pull', retry: 8, dead: false
  5. def perform(account_id, target_account_uri, relationship)
  6. from_account = Account.find(account_id)
  7. target_account = ResolveRemoteAccountService.new.call(target_account_uri)
  8. return if target_account.nil?
  9. case relationship
  10. when 'follow'
  11. FollowService.new.call(from_account, target_account.acct)
  12. when 'block'
  13. BlockService.new.call(from_account, target_account)
  14. when 'mute'
  15. MuteService.new.call(from_account, target_account)
  16. end
  17. rescue ActiveRecord::RecordNotFound
  18. true
  19. end
  20. end