[#593] Generate wiki content notifications in the JournalObserver - backported for 2.7
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
6fd9bc490f
commit
aa5be5132d
|
@ -16,8 +16,24 @@ 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')
|
||||
Mailer.deliver_wiki_content_added(wiki_content)
|
||||
end
|
||||
else
|
||||
if Setting.notified_events.include?('wiki_content_updated')
|
||||
Mailer.deliver_wiki_content_updated(wiki_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
clear_notification
|
||||
end
|
||||
|
|
|
@ -1,25 +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)
|
||||
Mailer.deliver_wiki_content_added(wiki_content) if Setting.notified_events.include?('wiki_content_added')
|
||||
end
|
||||
|
||||
def after_update(wiki_content)
|
||||
if wiki_content.text_changed?
|
||||
Mailer.deliver_wiki_content_updated(wiki_content) if Setting.notified_events.include?('wiki_content_updated')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -58,7 +58,7 @@ Rails::Initializer.run do |config|
|
|||
|
||||
# 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
|
||||
|
|
Loading…
Reference in New Issue