diff options
Diffstat (limited to 'lib/tasks/mastodon.rake')
-rw-r--r-- | lib/tasks/mastodon.rake | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 2f2d10a48..985747936 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -53,8 +53,18 @@ namespace :mastodon do task remove_remote: :environment do MediaAttachment.where.not(remote_url: '').where('created_at < ?', 1.week.ago).find_each do |media| media.file.destroy + media.type = :unknown + media.save end end + + desc 'Set unknown attachment type for remote-only attachments' + task set_unknown: :environment do + Rails.logger.debug 'Setting unknown attachment type for remote-only attachments...' + # rubocop:disable Rails/SkipsModelValidations + MediaAttachment.where(file_file_name: nil).where.not(type: :unknown).in_batches.update_all(type: :unknown) + Rails.logger.debug 'Done!' + end end namespace :push do |