2020-07-31 14:09:45 +02:00
|
|
|
class DeliverMessageJob < ApplicationJob
|
|
|
|
def perform(message)
|
2019-10-29 01:19:05 +01:00
|
|
|
message.message_recipients.each do |message_recipient|
|
|
|
|
recipient = message_recipient.user
|
2017-08-18 00:45:17 +02:00
|
|
|
if recipient.receive_email?
|
2017-08-18 01:04:41 +02:00
|
|
|
Mailer.deliver_now_with_user_locale recipient do
|
|
|
|
MessagesMailer.foodsoft_message(recipient, message)
|
2017-08-18 00:45:17 +02:00
|
|
|
end
|
2019-10-29 01:19:05 +01:00
|
|
|
message_recipient.update_attribute :email_state, :sent
|
|
|
|
else
|
|
|
|
message_recipient.update_attribute :email_state, :skipped
|
2017-08-18 00:45:17 +02:00
|
|
|
end
|
|
|
|
end
|
2014-03-07 09:51:24 +01:00
|
|
|
end
|
|
|
|
end
|