Updated accounts_cli

• Updated:
- accounts_cli
This commit is contained in:
mgabdev 2021-01-10 17:17:20 -05:00
parent 44b3484cb2
commit ca8337b937
1 changed files with 15 additions and 4 deletions

View File

@ -342,6 +342,7 @@ module GabSocial
say("OK, followed target from #{processed} accounts, skipped #{failed}", :green) say("OK, followed target from #{processed} accounts, skipped #{failed}", :green)
end end
option :number, type: :numeric, aliases: [:n]
desc 'unfollow ACCT', 'Make all local accounts unfollow account specified by ACCT' desc 'unfollow ACCT', 'Make all local accounts unfollow account specified by ACCT'
long_desc <<-LONG_DESC long_desc <<-LONG_DESC
Make all local accounts unfollow an account specified by ACCT. ACCT can be Make all local accounts unfollow an account specified by ACCT. ACCT can be
@ -349,7 +350,17 @@ module GabSocial
username@domain, in case of a remote user. username@domain, in case of a remote user.
LONG_DESC LONG_DESC
def unfollow(acct) def unfollow(acct)
target_account = Account.find_remote(*acct.split('@')) target_account = nil
followers = nil
if options[:number]
target_account = Account.find(acct)
followers = target_account.followers.local.limit(options[:number]).reorder(created_at: :asc)
else
say('Error. Specify a limit', :red)
exit(1)
end
processed = 0 processed = 0
failed = 0 failed = 0
@ -358,7 +369,7 @@ module GabSocial
exit(1) exit(1)
end end
target_account.followers.local.find_each do |account| followers.find_each do |account|
begin begin
UnfollowService.new.call(account, target_account) UnfollowService.new.call(account, target_account)
processed += 1 processed += 1