FIX: when no notification state exists on topic, mute on unsubscribe

This commit is contained in:
Sam 2016-04-25 11:24:52 +10:00
parent 7ee11b0508
commit 0b6d12f95d
1 changed files with 3 additions and 3 deletions

View File

@ -121,13 +121,13 @@ class TopicsController < ApplicationController
tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id])
if tu.notification_level > TopicUser.notification_levels[:regular]
if tu && tu.notification_level > TopicUser.notification_levels[:regular]
tu.notification_level = TopicUser.notification_levels[:regular]
tu.save!
else
tu.notification_level = TopicUser.notification_levels[:muted]
TopicUser.change(current_user.id, params[:topic_id].to_i, notification_level: TopicUser.notification_levels[:muted])
end
tu.save!
perform_show_response
end