From 059ebbf48dc56971b88e26a15303a75643de8b98 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 20 Sep 2016 00:39:03 +0200 Subject: Separate PuSH subscriptions from following, add mastodon:push:refresh task, respect hub.lease_seconds (fix #46) --- lib/tasks/mastodon.rake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/tasks') diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index f59cdfcae..5bc056a56 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -11,9 +11,16 @@ namespace :mastodon do namespace :push do desc 'Unsubscribes from PuSH updates of feeds nobody follows locally' task clear: :environment do - Account.where('(select count(f.id) from follows as f where f.target_account_id = accounts.id) = 0').where.not(domain: nil).find_each do |a| + Account.remote.without_followers.find_each do |a| a.subscription('').unsubscribe - a.update!(verify_token: '', secret: '') + a.update!(verify_token: '', secret: '', subscription_expires_at: nil) + end + end + + desc 'Re-subscribes to soon expiring PuSH subscriptions' + task refresh: :environment do + Account.expiring(1.day.from_now).find_each do |a| + SubscribeService.new.(a) end end end -- cgit