Add refreshing many accounts at once with "tootctl accounts refresh" (#23304)
parent
cec59417d7
commit
78c7c79d78
|
@ -372,16 +372,16 @@ module Mastodon
|
||||||
option :concurrency, type: :numeric, default: 5, aliases: [:c]
|
option :concurrency, type: :numeric, default: 5, aliases: [:c]
|
||||||
option :verbose, type: :boolean, aliases: [:v]
|
option :verbose, type: :boolean, aliases: [:v]
|
||||||
option :dry_run, type: :boolean
|
option :dry_run, type: :boolean
|
||||||
desc 'refresh [USERNAME]', 'Fetch remote user data and files'
|
desc 'refresh [USERNAMES]', 'Fetch remote user data and files'
|
||||||
long_desc <<-LONG_DESC
|
long_desc <<-LONG_DESC
|
||||||
Fetch remote user data and files for one or multiple accounts.
|
Fetch remote user data and files for one or multiple accounts.
|
||||||
|
|
||||||
With the --all option, all remote accounts will be processed.
|
With the --all option, all remote accounts will be processed.
|
||||||
Through the --domain option, this can be narrowed down to a
|
Through the --domain option, this can be narrowed down to a
|
||||||
specific domain only. Otherwise, a single remote account must
|
specific domain only. Otherwise, remote accounts must be
|
||||||
be specified with USERNAME.
|
specified with space-separated USERNAMES.
|
||||||
LONG_DESC
|
LONG_DESC
|
||||||
def refresh(username = nil)
|
def refresh(*usernames)
|
||||||
dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
|
dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
|
||||||
|
|
||||||
if options[:domain] || options[:all]
|
if options[:domain] || options[:all]
|
||||||
|
@ -397,19 +397,25 @@ module Mastodon
|
||||||
end
|
end
|
||||||
|
|
||||||
say("Refreshed #{processed} accounts#{dry_run}", :green, true)
|
say("Refreshed #{processed} accounts#{dry_run}", :green, true)
|
||||||
elsif username.present?
|
elsif !usernames.empty?
|
||||||
username, domain = username.split('@')
|
usernames.each do |user|
|
||||||
account = Account.find_remote(username, domain)
|
user, domain = user.split('@')
|
||||||
|
account = Account.find_remote(user, domain)
|
||||||
|
|
||||||
if account.nil?
|
if account.nil?
|
||||||
say('No such account', :red)
|
say('No such account', :red)
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
unless options[:dry_run]
|
next if options[:dry_run]
|
||||||
account.reset_avatar!
|
|
||||||
account.reset_header!
|
begin
|
||||||
account.save
|
account.reset_avatar!
|
||||||
|
account.reset_header!
|
||||||
|
account.save
|
||||||
|
rescue Mastodon::UnexpectedResponseError
|
||||||
|
say("Account failed: #{user}@#{domain}", :red)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
say("OK#{dry_run}", :green)
|
say("OK#{dry_run}", :green)
|
||||||
|
|
Reference in New Issue