about summary refs log tree commit diff
path: root/lib/tasks/subscriptions.rake
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks/subscriptions.rake')
-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