fix: Disable syncing IMAP if the account is suspended (#11031)

This PR disables the IMAP syncing if the account is suspended.
This commit is contained in:
Pranav
2025-03-05 17:10:24 -08:00
committed by GitHub
parent c1f6d9f76f
commit d017156f32
3 changed files with 39 additions and 7 deletions

View File

@@ -2,8 +2,15 @@ class Inboxes::FetchImapEmailInboxesJob < ApplicationJob
queue_as :scheduled_jobs
def perform
Inbox.where(channel_type: 'Channel::Email').all.find_each(batch_size: 100) do |inbox|
::Inboxes::FetchImapEmailsJob.perform_later(inbox.channel) if inbox.channel.imap_enabled
email_inboxes = Inbox.where(channel_type: 'Channel::Email')
email_inboxes.find_each(batch_size: 100) do |inbox|
::Inboxes::FetchImapEmailsJob.perform_later(inbox.channel) if should_fetch_emails?(inbox)
end
end
private
def should_fetch_emails?(inbox)
inbox.channel.imap_enabled && !inbox.account.suspended?
end
end