The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

32 lines
910 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 = ResolveAccountService.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)
  12. when 'unfollow'
  13. UnfollowService.new.call(from_account, target_account)
  14. when 'block'
  15. BlockService.new.call(from_account, target_account)
  16. when 'unblock'
  17. UnblockService.new.call(from_account, target_account)
  18. when 'mute'
  19. MuteService.new.call(from_account, target_account)
  20. when 'unmute'
  21. UnmuteService.new.call(from_account, target_account)
  22. end
  23. rescue ActiveRecord::RecordNotFound
  24. true
  25. end
  26. end