Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
# Automatically retry jobs that encountered a deadlock
|
||||
# retry_on ActiveRecord::Deadlocked
|
||||
|
||||
# Most jobs are safe to ignore if the underlying records are no longer available
|
||||
# discard_on ActiveJob::DeserializationError
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
class SendMailingRecipientJob < ApplicationJob
|
||||
queue_as :mailers
|
||||
|
||||
def perform(recipient_id)
|
||||
recipient = MailingRecipient.find_by(id: recipient_id)
|
||||
return if recipient.nil?
|
||||
|
||||
mailing = recipient.mailing
|
||||
return unless mailing.sending?
|
||||
return unless recipient.pending? || recipient.status == "queued"
|
||||
|
||||
begin
|
||||
CampaignMailer.raise_delivery_errors = true
|
||||
recipient.deliver!
|
||||
ensure
|
||||
CampaignMailer.raise_delivery_errors = false if Rails.env.development?
|
||||
end
|
||||
|
||||
nxt = mailing.mailing_recipients.pending.order(:id).first
|
||||
return if nxt.nil?
|
||||
|
||||
wait = mailing.interval_seconds.to_i.seconds
|
||||
if wait.positive?
|
||||
self.class.set(wait: wait).perform_later(nxt.id)
|
||||
else
|
||||
self.class.perform_later(nxt.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user