FIX: Update auto_notification to also update the subscription state when replying if the current state is less than the state being requested

This commit is contained in:
cpradio 2017-04-14 15:44:42 -04:00
parent ed2e62f845
commit 4dc4c5bebc

View File

@ -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