Add retry_follow_request to tootctl

This commit is contained in:
noellabo 2023-02-20 05:05:38 +09:00
parent fbec5236d9
commit 0ab9fcb667
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,26 @@
# frozen_string_literal: true
class RetryFollowRequestWorker
include Sidekiq::Worker
sidekiq_options queue: 'pull', retry: false
def perform(target_account_id)
target_account = Account.find(target_account_id)
return unless target_account.activitypub?
FollowRequest.where(target_account: target_account).find_each do |follow_request|
reblogs = follow_request.show_reblogs?
notify = follow_request.notify?
delivery = follow_request.delivery?
follower = follow_request.account
begin
UnfollowService.new.call(follower, target_account, skip_unmerge: true)
FollowService.new.call(follower, target_account, reblogs: reblogs, notify: notify, delivery: delivery, bypass_limit: true)
rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError
next
end
end
end
end

View File

@ -515,6 +515,23 @@ module Mastodon
end
end
desc 'retry_follow_request ACCT', 'Retry follow request'
long_desc <<-LONG_DESC
Retry follow request.
LONG_DESC
def retry_follow_request(acct = nil)
username, domain = acct.split('@')
target_account = Account.find_remote(username, domain)
if target_account.nil?
say('No account(s) given', :red)
exit(1)
end
RetryFollowRequestWorker.perform_async(target_account.id)
say('OK', :green)
end
private
def rotate_keys_for_account(account, delay = 0)