From 5fa5c18a487157259e887ada4a5c9fb37ddc3b80 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Wed, 19 Apr 2017 16:17:24 +0530 Subject: [PATCH] use notification_levels methods for specifying normal notification level --- app/models/topic_user.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/topic_user.rb b/app/models/topic_user.rb index 65941a8a64d..7dd30be2df2 100644 --- a/app/models/topic_user.rb +++ b/app/models/topic_user.rb @@ -39,8 +39,9 @@ class TopicUser < ActiveRecord::Base def auto_notification(user_id, topic_id, reason, notification_level) if TopicUser.where("user_id = :user_id AND topic_id = :topic_id AND (notifications_reason_id IS NULL OR - (notification_level < :notification_level AND notification_level > 1))", - user_id: user_id, topic_id: topic_id, notification_level: notification_level).exists? + (notification_level < :notification_level AND notification_level > :normal_notification_level))", + user_id: user_id, topic_id: topic_id, notification_level: notification_level, + normal_notification_level: notification_levels[:regular]).exists? change(user_id, topic_id, notification_level: notification_level, notifications_reason_id: reason