foodsoft/plugins/messages/app/workers/message_notifier.rb

21 lines
524 B
Ruby
Raw Normal View History

2014-03-07 09:51:24 +01:00
class MessageNotifier < UserNotifier
@queue = :foodsoft_notifier
def self.message_deliver(args)
message_id = args.first
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