Change terms of service e-mail job to be iterable (#35126)
This commit is contained in:
parent
e60014ed9c
commit
1be48d0cab
3 changed files with 49 additions and 16 deletions
25
app/workers/concerns/bulk_mailer.rb
Normal file
25
app/workers/concerns/bulk_mailer.rb
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module BulkMailer
|
||||
def push_bulk_mailer(mailer_class, mailer_method, args_array)
|
||||
raise ArgumentError, "No method #{mailer_method} on class #{mailer_class.name}" unless mailer_class.respond_to?(mailer_method)
|
||||
|
||||
job_class = ActionMailer::MailDeliveryJob
|
||||
|
||||
Sidekiq::Client.push_bulk({
|
||||
'class' => ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper,
|
||||
'wrapped' => job_class,
|
||||
'queue' => mailer_class.deliver_later_queue_name,
|
||||
'args' => args_array.map do |args|
|
||||
[
|
||||
job_class.new(
|
||||
mailer_class.name,
|
||||
mailer_method.to_s,
|
||||
'deliver_now',
|
||||
args: args
|
||||
).serialize,
|
||||
]
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue