Move code for sending the messages from model to MessageNotifier
This commit is contained in:
parent
add281c738
commit
3f7efbc4b9
2 changed files with 13 additions and 18 deletions
|
|
@ -3,6 +3,18 @@ class MessageNotifier < UserNotifier
|
|||
|
||||
def self.message_deliver(args)
|
||||
message_id = args.first
|
||||
Message.find(message_id).deliver
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue