2014-03-07 09:51:24 +01:00
|
|
|
class MessageNotifier < UserNotifier
|
|
|
|
@queue = :foodsoft_notifier
|
|
|
|
|
|
|
|
def self.message_deliver(args)
|
|
|
|
message_id = args.first
|
2017-08-18 00:45:17 +02:00
|
|
|
message = Message.find(message_id)
|
|
|
|
|
|
|
|
message.recipients.each do |recipient|
|
|
|
|
if recipient.receive_email?
|
|
|
|
begin
|
|
|
|
MessagesMailer.foodsoft_message(message, recipient).deliver
|
|
|
|
rescue
|
|
|
|
Rails.logger.warn "Deliver failed for user \##{recipient.id}: #{recipient.email}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
message.update_attribute(:email_state, 1)
|
2014-03-07 09:51:24 +01:00
|
|
|
end
|
|
|
|
end
|