From d680885660646d2868e06a2545562a315ab08c4f Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Fri, 6 Mar 2009 20:08:11 +0100 Subject: [PATCH] Fixed bugs in message system. --- app/models/mailer.rb | 13 +++++++------ app/models/message.rb | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index d2cccd99..bab5eaf2 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -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. diff --git a/app/models/message.rb b/app/models/message.rb index ef45538e..f71c8385 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -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)