From 37af13f6eaf78618e0693f92391b7e7513baa035 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 2 Oct 2014 16:03:56 +1000 Subject: [PATCH] FIX: badge notifications are marked read by the system after opening --- app/models/user.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 4db9f08b107..4c1d5f017b3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -255,8 +255,12 @@ class User < ActiveRecord::Base end def saw_notification_id(notification_id) - User.where(["id = ? and seen_notification_id < ?", id, notification_id]) + User.where("id = ? and seen_notification_id < ?", id, notification_id) .update_all ["seen_notification_id = ?", notification_id] + + # mark all badge notifications read + Notification.where('user_id = ? AND NOT read AND notification_type = ?', id, Notification.types[:granted_badge]) + .update_all ["read = ?", true] end def publish_notifications_state