mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08:00
FIX: when no notification state exists on topic, mute on unsubscribe
This commit is contained in:
parent
7ee11b0508
commit
0b6d12f95d
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user