discourse/app/jobs/regular/process_email.rb
Martin Brennan fb184fed06
DEV: Add created_via column to IncomingEmail (#11751)
This should make it easier to track down how the incoming email was created, which is one of four locations:

The POP3 poller (which picks up reply via email replies)
The admin email controller #handle_mail (which is where hosted mail is sent)
The IMAP sync tool
The group SMTP mailer, which sends emails when replying to IMAP topics, pre-emptively creating IncomingEmail records to avoid double syncing
2021-01-20 13:22:41 +10:00

23 lines
473 B
Ruby

# frozen_string_literal: true
module Jobs
class ProcessEmail < ::Jobs::Base
sidekiq_options retry: 3
def execute(args)
Email::Processor.process!(
args[:mail],
retry_on_rate_limit: args[:retry_on_rate_limit] || false,
source: args[:source]&.to_sym
)
end
sidekiq_retries_exhausted do |msg|
Rails.logger.warn("Incoming email could not be processed after 3 retries.\n\n#{msg["args"][:mail]}")
end
end
end