0
0
Fork 0

Separate PuSH subscriptions from following, add mastodon:push:refresh task,

respect hub.lease_seconds (fix #46)
This commit is contained in:
Eugen Rochko 2016-09-20 00:39:03 +02:00
parent 1245ee42fb
commit 059ebbf48d
10 changed files with 77 additions and 43 deletions

View file

@ -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