trabajo-afectivo/app/jobs/imap_authentication_migration_cleanup_job.rb
2022-01-01 14:38:12 +01:00

16 lines
538 B
Ruby

# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class ImapAuthenticationMigrationCleanupJob < ApplicationJob
include HasActiveJobLock
def perform
Channel.where(area: ['Google::Account', 'Microsoft365::Account']).find_each do |channel|
next if channel.options.blank?
next if channel.options[:backup_imap_classic].blank?
next if channel.options[:backup_imap_classic][:migrated_at] > 7.days.ago
channel.options.delete(:backup_imap_classic)
channel.save!
end
end
end