@@ -329,17 +329,19 @@ def assign(
329329 publish_assignment ( assignment , assign_to , note , status )
330330
331331 if assignment . assigned_to_user?
332- if !TopicUser . exists? (
333- user_id : assign_to . id ,
334- topic_id : topic . id ,
335- notification_level : TopicUser . notification_levels [ :watching ] ,
336- )
337- TopicUser . change (
338- assign_to . id ,
339- topic . id ,
340- notification_level : TopicUser . notification_levels [ :watching ] ,
341- notifications_reason_id : TopicUser . notification_reasons [ :plugin_changed ] ,
342- )
332+ if !assign_to . user_option . do_nothing_when_assigned?
333+ notification_level =
334+ if assign_to . user_option . track_topic_when_assigned?
335+ TopicUser . notification_levels [ :tracking ]
336+ else
337+ TopicUser . notification_levels [ :watching ]
338+ end
339+
340+ topic_user = TopicUser . find_by ( user_id : assign_to . id , topic :)
341+ if !topic_user || topic_user . notification_level < notification_level
342+ notifications_reason_id = TopicUser . notification_reasons [ :plugin_changed ]
343+ TopicUser . change ( assign_to . id , topic . id , notification_level :, notifications_reason_id :)
344+ end
343345 end
344346
345347 if SiteSetting . assign_mailer == AssignMailer . levels [ :always ] ||
@@ -506,6 +508,7 @@ def add_small_action_post(action_code, assign_to, text)
506508 @assigned_by ,
507509 text ,
508510 bump : false ,
511+ auto_track : false ,
509512 post_type : SiteSetting . assigns_public ? Post . types [ :small_action ] : Post . types [ :whisper ] ,
510513 action_code : action_code ,
511514 custom_fields : custom_fields ,
0 commit comments