diff --git a/app/models/notification.rb b/app/models/notification.rb index f9611d2a6c0..303025b2d4e 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -35,8 +35,14 @@ class Notification < ActiveRecord::Base end def self.mark_posts_read(user, topic_id, post_numbers) - Notification.where(user_id: user.id, topic_id: topic_id, post_number: post_numbers, read: false).update_all "read = 't'" - user.publish_notifications_state + count = Notification + .where(user_id: user.id, + topic_id: topic_id, + post_number: post_numbers, + read: false) + .update_all("read = 't'") + + user.publish_notifications_state if count > 0 end def self.interesting_after(min_date)