Permalink
Browse files

Only notify if the subscription exists

  • Loading branch information...
1 parent 396b412 commit 41ca9e01f8de05e7232c1318917b5ddabedc0b39 @titanous titanous committed Oct 3, 2012
@@ -65,6 +65,11 @@ def self.notify_entity(entity, post_id, view='full')
res
end
+ def self.notify(subscription_id, post_id)
+ subscription = first(:id => subscription_id)
+ subscription.notify_about(post_id) if subscription
+ end
+
def notify_about(post_id, view='full')
post = Post.first(:id => post_id)
return unless post
@@ -12,7 +12,7 @@ def self.queue_job(job, msg)
end
NOTIFY_QUEUE = GirlFriday::WorkQueue.new(:notify) do |msg|
- Model::NotificationSubscription.first(:id => msg[:subscription_id]).notify_about(msg[:post_id], msg[:view])
+ Model::NotificationSubscription.notify(msg[:subscription_id], msg[:post_id])
end
NOTIFY_ENTITY_QUEUE = GirlFriday::WorkQueue.new(:notify_entity) do |msg|
@@ -19,7 +19,7 @@ class NotifyWorker
include Sidekiq::Worker
def perform(msg)
- Model::NotificationSubscription.first(:id => msg['subscription_id']).notify_about(msg['post_id'])
+ Model::NotificationSubscription.notify(msg['subscription_id'], msg['post_id'])
end
end

0 comments on commit 41ca9e0

Please sign in to comment.