diff options
author | beatrix <beatrix.bitrot@gmail.com> | 2017-09-09 20:11:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-09 20:11:48 -0400 |
commit | 3dff74eecf5387b92b862893248710d2efb90eec (patch) | |
tree | 0d29d8c952a0c62e7de4348a1d63963fd5eca237 /lib/tasks | |
parent | e18ed4bbc7ab4e258d05a3e2a5db0790f67a8f37 (diff) | |
parent | 14e1fb8d36763e5255e7b8e440ecaf02208db004 (diff) |
Merge pull request #141 from yipdw/sync/upstream
Sync with upstream @ v1.6.0rc3 ohhhhhhhhhhh heck here we go
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/mastodon.rake | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 226523554..307bc240d 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -111,10 +111,7 @@ namespace :mastodon do namespace :push do desc 'Unsubscribes from PuSH updates of feeds nobody follows locally' task clear: :environment do - Account.remote.without_followers.where.not(subscription_expires_at: nil).find_each do |a| - Rails.logger.debug "PuSH unsubscribing from #{a.acct}" - UnsubscribeService.new.call(a) - end + Pubsubhubbub::UnsubscribeWorker.push_bulk(Account.remote.without_followers.where.not(subscription_expires_at: nil).pluck(:id)) end desc 'Re-subscribes to soon expiring PuSH subscriptions (deprecated)' @@ -273,5 +270,35 @@ namespace :mastodon do ActiveRecord::Base.connection.execute('UPDATE media_attachments SET account_id = NULL FROM media_attachments ma LEFT JOIN accounts a ON a.id = ma.account_id WHERE media_attachments.id = ma.id AND ma.account_id IS NOT NULL AND a.id IS NULL') ActiveRecord::Base.connection.execute('UPDATE reports SET action_taken_by_account_id = NULL FROM reports r LEFT JOIN accounts a ON a.id = r.action_taken_by_account_id WHERE reports.id = r.id AND r.action_taken_by_account_id IS NOT NULL AND a.id IS NULL') end + + desc 'Remove deprecated preview cards' + task remove_deprecated_preview_cards: :environment do + next unless ActiveRecord::Base.connection.table_exists? 'deprecated_preview_cards' + + class DeprecatedPreviewCard < ActiveRecord::Base + self.inheritance_column = false + + path = '/preview_cards/:attachment/:id_partition/:style/:filename' + if ENV['S3_ENABLED'] != 'true' + path = (ENV['PAPERCLIP_ROOT_PATH'] || ':rails_root/public/system') + path + end + + has_attached_file :image, styles: { original: '280x120>' }, convert_options: { all: '-quality 80 -strip' }, path: path + end + + puts 'Delete records and associated files from deprecated preview cards? [y/N]: ' + confirm = STDIN.gets.chomp + + if confirm.casecmp?('y') + DeprecatedPreviewCard.in_batches.destroy_all + + puts 'Drop deprecated preview cards table? [y/N]: ' + confirm = STDIN.gets.chomp + + if confirm.casecmp?('y') + ActiveRecord::Migration.drop_table :deprecated_preview_cards + end + end + end end end |