Sha256: 95f5feb706d325116496e6c81eb0a7156825a7a9b306f660551cf7b8a9119e25

Contents?: true

Size: 952 Bytes

Versions: 9

Compression:

Stored size: 952 Bytes

Contents

module Gluttonberg
  class CommentSubscription < ActiveRecord::Base
    self.table_name = "gb_comment_subscriptions"

    before_save    :generate_reference_hash
    belongs_to     :article

    attr_accessible :article_id , :author_email , :author_name

    def self.notify_subscribers_of(article , comment)
      subscribers = self.find(:all , :conditions => {:article_id => article.id})
      subscribers.each do |subscriber|
        unless subscriber.author_email == comment.writer_email
          Notifier.delay.comment_notification(subscriber , article , comment ) #.deliver # its using delayed job but i am setting sent time immediately
          comment.notification_sent_at = Time.now
          comment.save
        end
      end
    end

    def generate_reference_hash
      unless self.reference_hash
        self.reference_hash = Digest::SHA1.hexdigest(Time.now.to_s + self.author_email + self.article_id.to_s)
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gluttonberg-core-2.6.4 app/models/gluttonberg/comment_subscription.rb
gluttonberg-core-2.6.3 app/models/gluttonberg/comment_subscription.rb
gluttonberg-core-2.6.2 app/models/gluttonberg/comment_subscription.rb
gluttonberg-core-2.6.1 app/models/gluttonberg/comment_subscription.rb
gluttonberg-core-2.6.0 app/models/gluttonberg/comment_subscription.rb
gluttonberg-core-2.5.9 app/models/gluttonberg/comment_subscription.rb
gluttonberg-core-2.5.8 app/models/gluttonberg/comment_subscription.rb
gluttonberg-core-2.5.7 app/models/gluttonberg/comment_subscription.rb
gluttonberg-core-2.5.6 app/models/gluttonberg/comment_subscription.rb