Use ActiveJob instead of Resque directly
This allows us to directly pass entities to the job.
This commit is contained in:
parent
07c8393c8c
commit
47d9c79617
16 changed files with 76 additions and 73 deletions
15
plugins/messages/app/jobs/deliver_message_job.rb
Normal file
15
plugins/messages/app/jobs/deliver_message_job.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
class DeliverMessageJob < ApplicationJob
|
||||
def perform(message)
|
||||
message.message_recipients.each do |message_recipient|
|
||||
recipient = message_recipient.user
|
||||
if recipient.receive_email?
|
||||
Mailer.deliver_now_with_user_locale recipient do
|
||||
MessagesMailer.foodsoft_message(recipient, message)
|
||||
end
|
||||
message_recipient.update_attribute :email_state, :sent
|
||||
else
|
||||
message_recipient.update_attribute :email_state, :skipped
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue