Add retry_follow_request to tootctl
This commit is contained in:
parent
fbec5236d9
commit
0ab9fcb667
|
@ -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
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue