message mail delivery must happen after the first journal is created

This commit is contained in:
Tim Felgentreff 2010-09-15 17:10:22 +02:00
parent bb37aa24dc
commit 53fd34fbd0
1 changed files with 5 additions and 2 deletions

View File

@ -16,7 +16,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class MessageObserver < ActiveRecord::Observer
def after_create(message)
Mailer.deliver_message_posted(message) if Setting.notified_events.include?('message_posted')
def after_save(message)
if message.last_journal.version == 1
# Only deliver mails for the first journal
Mailer.deliver_message_posted(message) if Setting.notified_events.include?('message_posted')
end
end
end