From cdd5ef691bcdb25f8c8367698de7e09301ee3528 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 4 Oct 2017 00:39:32 +0200 Subject: Use separate workers to process imports, retry failures (#5207) --- app/workers/import/relationship_worker.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/workers/import/relationship_worker.rb (limited to 'app/workers/import') 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 -- cgit