You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.5 KiB

  1. namespace :mastodon do
  2. namespace :media do
  3. desc 'Removes media attachments that have not been assigned to any status for longer than a day'
  4. task clear: :environment do
  5. MediaAttachment.where(status_id: nil).where('created_at < ?', 1.day.ago).find_each do |m|
  6. m.destroy
  7. end
  8. end
  9. end
  10. namespace :push do
  11. desc 'Unsubscribes from PuSH updates of feeds nobody follows locally'
  12. task clear: :environment do
  13. include RoutingHelper
  14. Account.remote.without_followers.find_each do |a|
  15. Rails.logger.debug "PuSH unsubscribing from #{a.acct}"
  16. begin
  17. a.subscription(api_subscription_url(a.id)).unsubscribe
  18. rescue HTTP::Error, OpenSSL::SSL::SSLError
  19. Rails.logger.debug "PuSH unsubscribing from #{a.acct} failed due to an HTTP or SSL error"
  20. ensure
  21. a.update!(secret: '', subscription_expires_at: nil)
  22. end
  23. end
  24. end
  25. desc 'Re-subscribes to soon expiring PuSH subscriptions'
  26. task refresh: :environment do
  27. Account.expiring(1.day.from_now).find_each do |a|
  28. Rails.logger.debug "PuSH re-subscribing to #{a.acct}"
  29. SubscribeService.new.(a)
  30. end
  31. end
  32. end
  33. namespace :feeds do
  34. desc 'Clears all timelines so that they would be regenerated on next hit'
  35. task clear: :environment do
  36. $redis.keys('feed:*').each { |key| $redis.del(key) }
  37. end
  38. end
  39. namespace :graphs do
  40. desc 'Syncs all follow relationships to Neo4J'
  41. task sync: :environment do
  42. Follow.find_each(&:sync!)
  43. end
  44. end
  45. end