Skip to content

Commit

Permalink
[chiliproject#593] Generate wiki content notifications in the Journal…
Browse files Browse the repository at this point in the history
…Observer

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.
  • Loading branch information
meineerde committed Feb 6, 2012
1 parent 3f99ee6 commit aa3ab99
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
24 changes: 22 additions & 2 deletions app/models/journal_observer.rb
Expand Up @@ -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
Expand Down
32 changes: 0 additions & 32 deletions app/models/wiki_content_observer.rb

This file was deleted.

2 changes: 1 addition & 1 deletion config/environment.rb
Expand Up @@ -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
Expand Down

0 comments on commit aa3ab99

Please sign in to comment.