From 8b4bddf1c967e6c2daedd66b54ca9f61f6852975 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 3 Sep 2017 01:11:23 +0200 Subject: [PATCH] Instantly upgrade account to ActivityPub if we receive ActivityPub payload (#4766) --- app/controllers/activitypub/inboxes_controller.rb | 8 ++++++-- app/workers/resolve_remote_account_worker.rb | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 app/workers/resolve_remote_account_worker.rb diff --git a/app/controllers/activitypub/inboxes_controller.rb b/app/controllers/activitypub/inboxes_controller.rb index 5fce505fd2..b37910b364 100644 --- a/app/controllers/activitypub/inboxes_controller.rb +++ b/app/controllers/activitypub/inboxes_controller.rb @@ -26,8 +26,12 @@ class ActivityPub::InboxesController < Api::BaseController end def upgrade_account - return unless signed_request_account.subscribed? - Pubsubhubbub::UnsubscribeWorker.perform_async(signed_request_account.id) + if signed_request_account.ostatus? + signed_request_account.update(last_webfingered_at: nil) + ResolveRemoteAccountWorker.perform_async(signed_request_account.acct) + end + + Pubsubhubbub::UnsubscribeWorker.perform_async(signed_request_account.id) if signed_request_account.subscribed? end def process_payload diff --git a/app/workers/resolve_remote_account_worker.rb b/app/workers/resolve_remote_account_worker.rb new file mode 100644 index 0000000000..5dd84ccb6b --- /dev/null +++ b/app/workers/resolve_remote_account_worker.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class ResolveRemoteAccountWorker + include Sidekiq::Worker + + sidekiq_options queue: 'pull', unique: :until_executed + + def perform(uri) + ResolveRemoteAccountService.new.call(uri) + end +end