foodsoft/plugins/messages/app/jobs/deliver_message_job.rb
Patrick Gansterer 47d9c79617 Use ActiveJob instead of Resque directly
This allows us to directly pass entities to the job.
2021-03-08 12:30:58 +01:00

15 lines
497 B
Ruby

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