BUGFIX: filter by topic

This commit is contained in:
Sam 2014-01-20 17:53:30 +11:00
parent c7c1c937af
commit 76a250300a

View File

@ -64,7 +64,7 @@ class PostAlertObserver < ActiveRecord::Observer
next if user.blank? next if user.blank?
destroy_notifications(user, Notification.types[:private_message], post.topic) destroy_notifications(user, Notification.types[:private_message], post.topic)
unread_post = first_unread_post(user,post.topic) unread_post = first_unread_post(user,post.topic) || post
create_notification(user, Notification.types[:private_message], unread_post) create_notification(user, Notification.types[:private_message], unread_post)
end end
elsif post.post_type != Post.types[:moderator_action] elsif post.post_type != Post.types[:moderator_action]
@ -84,6 +84,7 @@ class PostAlertObserver < ActiveRecord::Observer
SELECT last_read_post_number FROM topic_users tu SELECT last_read_post_number FROM topic_users tu
WHERE tu.user_id = ? AND tu.topic_id = ? ),0)', WHERE tu.user_id = ? AND tu.topic_id = ? ),0)',
user.id, topic.id) user.id, topic.id)
.where(topic_id: topic.id)
.order('post_number').first .order('post_number').first
end end