[#593] Generate wiki content notifications in the JournalObserver
This will prevent the usage of the wrong wiki_content status. The code is not overly pretty and deserves a thorough refactoring, but at least it solves the problem at hand.
This commit is contained in:
parent
3f99ee63ff
commit
aa3ab990d0
@ -16,9 +16,29 @@ class JournalObserver < ActiveRecord::Observer
|
|||||||
attr_accessor :send_notification
|
attr_accessor :send_notification
|
||||||
|
|
||||||
def after_create(journal)
|
def after_create(journal)
|
||||||
if journal.type == "IssueJournal" and !journal.initial? and send_notification
|
case journal.type
|
||||||
|
when "IssueJournal"
|
||||||
|
if !journal.initial? && send_notification
|
||||||
after_create_issue_journal(journal)
|
after_create_issue_journal(journal)
|
||||||
end
|
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
|
clear_notification
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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
|
|
@ -61,7 +61,7 @@ Rails::Initializer.run do |config|
|
|||||||
|
|
||||||
# Activate observers that should always be running
|
# Activate observers that should always be running
|
||||||
# config.active_record.observers = :cacher, :garbage_collector
|
# 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
|
# Make Active Record use UTC-base instead of local time
|
||||||
# config.active_record.default_timezone = :utc
|
# config.active_record.default_timezone = :utc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user