From 323474c97ee4adc2b905c3c754f7a137e06d1e81 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 17 Mar 2016 11:59:18 +0100 Subject: Fix #2, add rake task for PuSH-unsubscribing from remote users who have no local followers. Remote users' usernames SHOULD be case-sensitive --- lib/tasks/subscriptions.rake | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/tasks/subscriptions.rake (limited to 'lib/tasks/subscriptions.rake') diff --git a/lib/tasks/subscriptions.rake b/lib/tasks/subscriptions.rake new file mode 100644 index 000000000..875bd8ae6 --- /dev/null +++ b/lib/tasks/subscriptions.rake @@ -0,0 +1,13 @@ +namespace :subscriptions do + + desc "For all remote accounts that have no local followers, unsubscribe from PuSH" + task clear: :environment do + accounts = Account.where('(select count(f.id) from follows as f where f.target_account_id = accounts.id) = 0').where.not(domain: nil) + + accounts.each do |a| + a.subscription(api_subscription_url(a.id)).unsubscribe + a.update!(verify_token: '', secret: '') + end + end + +end -- cgit