diff options
Diffstat (limited to 'app/workers/import')
-rw-r--r-- | app/workers/import/relationship_worker.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/workers/import/relationship_worker.rb b/app/workers/import/relationship_worker.rb new file mode 100644 index 000000000..ed4c962c1 --- /dev/null +++ b/app/workers/import/relationship_worker.rb @@ -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 |