diff --git a/app/models/journal_observer.rb b/app/models/journal_observer.rb index acc357d05e..7ea174ffef 100644 --- a/app/models/journal_observer.rb +++ b/app/models/journal_observer.rb @@ -16,8 +16,28 @@ class JournalObserver < ActiveRecord::Observer attr_accessor :send_notification def after_create(journal) - if journal.type == "IssueJournal" and !journal.initial? and send_notification - after_create_issue_journal(journal) + case journal.type + when "IssueJournal" + if !journal.initial? && send_notification + after_create_issue_journal(journal) + end + when "WikiContentJournal" + wiki_content = journal.journaled + wiki_page = wiki_content.page + + if journal.initial? + if Setting.notified_events.include?('wiki_content_added') + (wiki_content.recipients + wiki_page.wiki.watcher_recipients).uniq.each do |recipient| + Mailer.deliver_wiki_content_added(wiki_content, recipient) + end + end + else + if Setting.notified_events.include?('wiki_content_updated') + (wiki_content.recipients + wiki_page.wiki.watcher_recipients + wiki_page.watcher_recipients).uniq.each do |recipient| + Mailer.deliver_wiki_content_updated(wiki_content, recipient) + end + end + end end clear_notification end diff --git a/app/models/wiki_content_observer.rb b/app/models/wiki_content_observer.rb deleted file mode 100644 index eb812d70f6..0000000000 --- a/app/models/wiki_content_observer.rb +++ /dev/null @@ -1,32 +0,0 @@ -#-- encoding: UTF-8 -#-- copyright -# ChiliProject is a project management system. -# -# Copyright (C) 2010-2012 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# See doc/COPYRIGHT.rdoc for more details. -#++ - -class WikiContentObserver < ActiveRecord::Observer - def after_create(wiki_content) - if Setting.notified_events.include?('wiki_content_added') - (wiki_content.recipients + wiki_content.page.wiki.watcher_recipients).uniq.each do |recipient| - Mailer.deliver_wiki_content_added(wiki_content, recipient) - end - end - end - - def after_update(wiki_content) - if wiki_content.text_changed? && Setting.notified_events.include?('wiki_content_updated') - - (wiki_content.recipients + wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients).uniq.each do |recipient| - Mailer.deliver_wiki_content_updated(wiki_content, recipient) - end - end - end -end diff --git a/config/environment.rb b/config/environment.rb index 49b2aeb61a..84d6d1ffff 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -61,7 +61,7 @@ # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector - config.active_record.observers = :journal_observer, :message_observer, :issue_observer, :news_observer, :document_observer, :wiki_content_observer, :comment_observer + config.active_record.observers = :journal_observer, :message_observer, :issue_observer, :news_observer, :document_observer, :comment_observer # Make Active Record use UTC-base instead of local time # config.active_record.default_timezone = :utc