summaryrefslogtreecommitdiffstats
path: root/app/models/news.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/news.rb')
-rw-r--r--app/models/news.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/news.rb b/app/models/news.rb
index c8a4112cc..2186beaed 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -33,6 +33,7 @@ class News < ActiveRecord::Base
acts_as_watchable
after_create :add_author_as_watcher
+ after_create :send_notification
scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
@@ -63,4 +64,10 @@ class News < ActiveRecord::Base
def add_author_as_watcher
Watcher.create(:watchable => self, :user => author)
end
+
+ def send_notification
+ if Setting.notified_events.include?('news_added')
+ Mailer.news_added(self).deliver
+ end
+ end
end