From 5b55dc2f375cac1a78bc70150a9473a74271ffdd Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Mon, 15 Nov 2010 17:39:33 +1300 Subject: Added comment notifications. --- app/models/blog/comment_mailer.rb | 1 + app/models/blog_comment.rb | 38 ++++++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 app/models/blog/comment_mailer.rb (limited to 'app/models') diff --git a/app/models/blog/comment_mailer.rb b/app/models/blog/comment_mailer.rb new file mode 100644 index 0000000..dac526d --- /dev/null +++ b/app/models/blog/comment_mailer.rb @@ -0,0 +1 @@ +require File.expand_path('../../../mailers/blog/comment_mailer', __FILE__) \ No newline at end of file diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 201f75c..b888e35 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -46,7 +46,7 @@ class BlogComment < ActiveRecord::Base before_create do |comment| unless BlogComment::Moderation.enabled? - comment.state = comment.spam? ? 'rejected' : 'approved' + comment.state = comment.ham? ? 'approved' : 'rejected' end end @@ -55,8 +55,7 @@ class BlogComment < ActiveRecord::Base def enabled? RefinerySetting.find_or_set(:comment_moderation, true, { :scoping => :blog, - :restricted => false, - :callback_proc_as_string => nil + :restricted => false }) end @@ -64,8 +63,7 @@ class BlogComment < ActiveRecord::Base RefinerySetting[:comment_moderation] = { :value => !self.enabled?, :scoping => :blog, - :restricted => false, - :callback_proc_as_string => nil + :restricted => false } end end @@ -74,21 +72,33 @@ class BlogComment < ActiveRecord::Base module Notification class << self def recipients - RefinerySetting.find_or_set(:comment_notification_recipients, - (Role[:refinery].users.first.email rescue ''), - { - :scoping => :blog, - :restricted => false, - :callback_proc_as_string => nil - }) + RefinerySetting.find_or_set(:comment_notification_recipients, (Role[:refinery].users.first.email rescue ''), + { + :scoping => :blog, + :restricted => false + }) end def recipients=(emails) RefinerySetting[:comment_notification_recipients] = { :value => emails, :scoping => :blog, - :restricted => false, - :callback_proc_as_string => nil + :restricted => false + } + end + + def subject + RefinerySetting.find_or_set(:comment_notification_subject, "New inquiry from your website", { + :scoping => :blog, + :restricted => false + }) + end + + def subject=(subject_line) + RefinerySetting[:comment_notification_subject] = { + :value => subject_line, + :scoping => :blog, + :restricted => false } end end -- cgit v1.2.3