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
# 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
recipients message.recipient.email
recipients recipient.email
from "#{message.sender.nick} <#{message.sender.email}>"
body :body => message.body,
:sender => message.sender.nick,
:recipients => message.recipients,
:reply => "#{APP_CONFIG[:base_url]}/messages/reply/#{message}",
:profile => "#{APP_CONFIG[:base_url]}/home/profile",
:link => "#{APP_CONFIG[:base_url]}/messages/show/#{message}"
:recipients => recipient.nick,
:reply => "#{APP_CONFIG[:base_url]}/messages/reply/#{message.id}",
:link => "#{APP_CONFIG[:base_url]}/messages/show/#{message.id}",
:profile => "#{APP_CONFIG[:base_url]}/home/profile"
end
# Sends an email with instructions on how to reset the password.

View file

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