diff --git a/app/models/topic_user.rb b/app/models/topic_user.rb index 36d47f77146..1816f34cbe1 100644 --- a/app/models/topic_user.rb +++ b/app/models/topic_user.rb @@ -112,6 +112,13 @@ class TopicUser < ActiveRecord::Base observe_after_save_callbacks_for topic_id, user_id end end + + if attrs[:notification_level] + MessageBus.publish("/topic/#{topic_id}", + {notification_level_change: attrs[:notification_level]}, user_ids: [user_id]) + end + + rescue ActiveRecord::RecordNotUnique # In case of a race condition to insert, do nothing end @@ -210,6 +217,8 @@ class TopicUser < ActiveRecord::Base FROM topic_users AS ftu WHERE ftu.user_id = :user_id and ftu.topic_id = :topic_id)", args) + + MessageBus.publish("/topic/#{topic_id}", {notification_level_change: args[:new_status]}, user_ids: [user.id]) end end