Fixed bugs in message system.

This commit is contained in:
Benjamin Meichsner 2009-03-06 20:08:11 +01:00
parent a30444a602
commit d680885660
2 changed files with 9 additions and 8 deletions

View file

@ -4,16 +4,17 @@ class Mailer < ActionMailer::Base
layout 'email' # Use views/layouts/email.html.erb layout 'email' # Use views/layouts/email.html.erb
# Sends an email copy of the given internal foodsoft message. # Sends an email copy of the given internal foodsoft message.
def message(message) def message(message, recipient)
headers 'Sender' => APP_CONFIG[:email_sender], 'Errors-To' => APP_CONFIG[:email_sender]
subject "[#{APP_CONFIG[:name]}] " + message.subject subject "[#{APP_CONFIG[:name]}] " + message.subject
recipients message.recipient.email recipients recipient.email
from "#{message.sender.nick} <#{message.sender.email}>" from "#{message.sender.nick} <#{message.sender.email}>"
body :body => message.body, body :body => message.body,
:sender => message.sender.nick, :sender => message.sender.nick,
:recipients => message.recipients, :recipients => recipient.nick,
:reply => "#{APP_CONFIG[:base_url]}/messages/reply/#{message}", :reply => "#{APP_CONFIG[:base_url]}/messages/reply/#{message.id}",
:profile => "#{APP_CONFIG[:base_url]}/home/profile", :link => "#{APP_CONFIG[:base_url]}/messages/show/#{message.id}",
:link => "#{APP_CONFIG[:base_url]}/messages/show/#{message}" :profile => "#{APP_CONFIG[:base_url]}/home/profile"
end end
# Sends an email with instructions on how to reset the password. # Sends an email with instructions on how to reset the password.

View file

@ -77,8 +77,8 @@ class Message < ActiveRecord::Base
messages = Message.pending messages = Message.pending
for message in messages for message in messages
for recipient in message.recipients for recipient in message.recipients
if recipient.settings['messages.sendAsEmail'] == 1 && !recipient.email.blank? if recipient.settings['messages.sendAsEmail'] == "1" && !recipient.email.blank?
Mailer.deliver_message(message) Mailer.deliver_message(message, recipient)
end end
end end
message.update_attribute(:email_state, 1) message.update_attribute(:email_state, 1)