Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Interim commit of comment notification

  • Loading branch information...
commit 58f65f810d550bcd5613c14637a579d9f7eefdab 1 parent 4f68570
Ryan Daigle authored
Showing with 21 additions and 0 deletions.
  1. +11 −0 app/models/comment_notifier.rb
  2. +10 −0 app/models/gist.rb
11 app/models/comment_notifier.rb
View
@@ -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
10 app/models/gist.rb
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
Please sign in to comment.
Something went wrong with that request. Please try again.