diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 5092bdd77d..5e6d0a4164 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -7246,6 +7246,7 @@ def do_update_message( muting_user, new_stream if new_stream is not None else stream_being_edited, topic_name if topic_name is not None else orig_topic_name, + ignore_duplicate=True, ) send_event(user_profile.realm, event, users_to_be_notified) diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py index 188ce7a166..68d213943a 100644 --- a/zerver/tests/test_message_edit.py +++ b/zerver/tests/test_message_edit.py @@ -1261,9 +1261,11 @@ class EditMessageTest(EditMessageTestCase): self.subscribe(aaron, stream_name) self.login_user(aaron) + already_muted_topic = "Already muted topic" muted_topics = [ [stream_name, "Topic1"], [stream_name, "Topic2"], + [stream_name, already_muted_topic], ] set_topic_mutes(hamlet, muted_topics) set_topic_mutes(cordelia, muted_topics) @@ -1331,6 +1333,20 @@ class EditMessageTest(EditMessageTestCase): self.assertFalse(topic_is_muted(hamlet, stream.id, change_all_topic_name)) self.assertTrue(topic_is_muted(hamlet, stream.id, change_later_topic_name)) + # Make sure we safely handle the case of the new topic being already muted. + check_update_message( + user_profile=hamlet, + message_id=message_id, + stream_id=None, + topic_name=already_muted_topic, + propagate_mode="change_all", + send_notification_to_old_thread=False, + send_notification_to_new_thread=False, + content=None, + ) + self.assertFalse(topic_is_muted(hamlet, stream.id, change_later_topic_name)) + self.assertTrue(topic_is_muted(hamlet, stream.id, already_muted_topic)) + change_one_topic_name = "Topic 1 edited change_one" check_update_message( user_profile=hamlet,