summaryrefslogtreecommitdiffstats
path: root/app/models/message.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-14 14:26:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-14 14:26:27 +0000
commit205eda8b33d69defecedf2d246858a46d3d1d7c0 (patch)
tree4aeb58588ec0fa06ca385fe032168d336970fe55 /app/models/message.rb
parent010bfc56e15f442e4e597ddc9c436361c61b1e7a (diff)
downloadredmine-205eda8b33d69defecedf2d246858a46d3d1d7c0.tar.gz
redmine-205eda8b33d69defecedf2d246858a46d3d1d7c0.zip
Use AR callbacks instead of observers (removed in Rails4) for notifications.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12021 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/message.rb')
-rw-r--r--app/models/message.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/message.rb b/app/models/message.rb
index 767223748..4335fefa9 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -45,6 +45,7 @@ class Message < ActiveRecord::Base
after_create :add_author_as_watcher, :reset_counters!
after_update :update_messages_board
after_destroy :reset_counters!
+ after_create :send_notification
scope :visible, lambda {|*args|
includes(:board => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_messages, *args))
@@ -105,4 +106,10 @@ class Message < ActiveRecord::Base
def add_author_as_watcher
Watcher.create(:watchable => self.root, :user => author)
end
+
+ def send_notification
+ if Setting.notified_events.include?('message_posted')
+ Mailer.message_posted(self).deliver
+ end
+ end
end