about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-17 11:59:18 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-17 12:02:45 +0100
commit323474c97ee4adc2b905c3c754f7a137e06d1e81 (patch)
tree87695c6a6ccad8521f2980fc670429f99c202f80 /lib
parentaf7ae348d7cd6fcc56bbd757d8619b6c9a2bb261 (diff)
Fix #2, add rake task for PuSH-unsubscribing from remote users who have no
local followers. Remote users' usernames SHOULD be case-sensitive
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/subscriptions.rake13
1 files changed, 13 insertions, 0 deletions
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