From 4dc4c5bebcbc37c3ad38aad12ad5f00b95377471 Mon Sep 17 00:00:00 2001 From: cpradio Date: Fri, 14 Apr 2017 15:44:42 -0400 Subject: [PATCH] FIX: Update auto_notification to also update the subscription state when replying if the current state is less than the state being requested --- app/models/topic_user.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/topic_user.rb b/app/models/topic_user.rb index eb6cceeaf59..6395394e630 100644 --- a/app/models/topic_user.rb +++ b/app/models/topic_user.rb @@ -38,7 +38,8 @@ class TopicUser < ActiveRecord::Base end def auto_notification(user_id, topic_id, reason, notification_level) - if TopicUser.where(user_id: user_id, topic_id: topic_id, notifications_reason_id: nil).exists? + if TopicUser.where("user_id = ? AND topic_id = ? AND (notifications_reason_id IS NULL OR notification_level < ?)", + user_id, topic_id, notification_level).exists? change(user_id, topic_id, notification_level: notification_level, notifications_reason_id: reason