Permalink
Browse files

Interim commit of comment notification

  • Loading branch information...
1 parent 4f68570 commit 58f65f810d550bcd5613c14637a579d9f7eefdab @rwdaigle committed Nov 30, 2012
Showing with 21 additions and 0 deletions.
  1. +11 −0 app/models/comment_notifier.rb
  2. +10 −0 app/models/gist.rb
@@ -0,0 +1,11 @@
+class CommentNotifier
+
+ class << self
+
+ def gist_commented(gist_id)
+ gist = Gist.find(gist_id)
+ user = gist.user
+ # Mail!
+ end
+ end
+end
View
@@ -8,6 +8,8 @@ class Gist < ActiveRecord::Base
belongs_to :user, :touch => true
has_many :files, :class_name => 'GistFile', :dependent => :delete_all
+ before_save :check_for_new_comments
+
scope :with_ids, lambda { |ids| where(ids.any? ? ["id in (?)", ids] : "1 = 0") }
scope :starred, where(starred: true)
scope :not_starred, where(["starred = ? OR starred IS NULL", false])
@@ -155,4 +157,12 @@ def indexed_attributes
}
end
+ private
+
+ def check_for_new_comments
+ if(comment_count_changed?)
+ QC.enqueue("CommentNotifier.gist_commented", id) if comment_count.to_i > comment_count_was.to_i
+ end
+ end
+
end

0 comments on commit 58f65f8

Please sign in to comment.