Skip to content
Permalink
Browse files

Add to reset all followee and followers

  • Loading branch information...
noellabo committed Mar 9, 2019
1 parent a91349d commit 2bb8f1b55972b837c248b3f19e01157a69c0d33b
Showing with 45 additions and 0 deletions.
  1. +45 −0 lib/mastodon/accounts_cli.rb
@@ -360,6 +360,51 @@ def unfollow(acct)
say("OK, unfollowed target from #{processed} accounts, skipped #{failed}", :green)
end

desc 'ffreset USERNAME', 'Reset all followee and followers for the specified USERNAME'
long_desc <<-LONG_DESC
Reset all followee and followers for the specified USERNAME.
LONG_DESC
def ffreset(username)
account = Account.find_local(username)

if account.nil?
say('No user with such username', :red)
exit(1)
end

processed_followee = 0
processed_follower = 0
failed = 0

say("Unfollow #{account.username}'s followee, this might take a while...")
Account.where(id: ::Follow.where(account: account).select(:target_account_id)).find_each do |target_account|
begin
UnfollowService.new.call(account, target_account)
processed_followee += 1
say('.', :green, false)
rescue StandardError
failed += 1
say('.', :red, false)
end
end

say("Unfollow #{account.username}'s follower, this might take a while...")
Account.where(id: ::Follow.where(target_account: account).select(:account_id)).find_each do |target_account|
begin
UnfollowService.new.call(target_account, account)
processed_follower += 1
say('.', :green, false)
rescue StandardError
failed += 1
say('.', :red, false)
end
end

BootstrapTimelineWorker.perform_async(account.id)

say("OK, unfollowed #{processed_followee} followees, #{processed_follower} followers, skipped #{failed}", :green)
end

private

def rotate_keys_for_account(account, delay = 0)

0 comments on commit 2bb8f1b

Please sign in to comment.
You can’t perform that action at this time.