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