Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_edit: Fix resolution notification not being sent twice.
Zixuan James Lic821127131d2
diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.pyindex 61b44aa3b1c..f243b8fb149 100644--- a/zerver/actions/message_edit.py+++ b/zerver/actions/message_edit.py@@ -134,14 +134,10 @@ def maybe_send_resolve_topic_notifications(changed_messages: List[Message],) -> bool:"""Returns True if resolve topic notifications were in fact sent."""-# Note that topics will have already been stripped in check_update_message.## This logic is designed to treat removing a weird "✔ ✔✔ "# prefix as unresolving the topic.- if old_topic.lstrip(RESOLVED_TOPIC_PREFIX) != new_topic.lstrip(RESOLVED_TOPIC_PREFIX):- return False-topic_resolved: bool = new_topic.startswith(RESOLVED_TOPIC_PREFIX) and not old_topic.startswith(RESOLVED_TOPIC_PREFIX)diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.pyindex 6e21afabdc1..03bf6ffa7d3 100644--- a/zerver/tests/test_message_edit.py+++ b/zerver/tests/test_message_edit.py@@ -2722,6 +2722,74 @@ class EditMessageTest(EditMessageTestCase):self.assert_length(messages, 1)self.assertEqual(messages[0].content, "First")+ def test_notify_resolve_and_move_topic(self) -> None:+ user_profile = self.example_user("hamlet")+ self.login("hamlet")+ stream = self.make_stream("public stream")+ topic = "test"+ self.subscribe(user_profile, stream.name)++ # Resolve a topic normally first+ msg_id = self.send_stream_message(user_profile, stream.name, "foo", topic_name=topic)+ resolved_topic = RESOLVED_TOPIC_PREFIX + topic+ result = self.client_patch(+ "/json/messages/" + str(msg_id),+ {+ "topic": resolved_topic,+ "propagate_mode": "change_all",+ },+ )+ self.assert_json_success(result)++ messages = get_topic_messages(user_profile, stream, resolved_topic)+ self.assert_length(messages, 2)+ self.assertEqual(+ messages[1].content,+ f"@_**{user_profile.full_name}|{user_profile.id}** has marked this topic as resolved.",+ )++ # Test unresolving a topic while moving it (✔ test -> bar)+ new_topic = "bar"+ result = self.client_patch(+ "/json/messages/" + str(msg_id),+ {+ "topic": new_topic,+ "propagate_mode": "change_all",+ },+ )+ self.assert_json_success(result)+ messages = get_topic_messages(user_profile, stream, new_topic)+ self.assert_length(messages, 4)+ self.assertEqual(+ messages[2].content,+ f"@_**{user_profile.full_name}|{user_profile.id}** has marked this topic as unresolved.",+ )+ self.assertEqual(+ messages[3].content,+ f"This topic was moved here from #**public stream>✔ test** by @_**{user_profile.full_name}|{user_profile.id}**.",+ )++ # Now test moving the topic while also resolving it (bar -> ✔ baz)+ new_resolved_topic = RESOLVED_TOPIC_PREFIX + "baz"+ result = self.client_patch(+ "/json/messages/" + str(msg_id),+ {+ "topic": new_resolved_topic,+ "propagate_mode": "change_all",+ },+ )+ self.assert_json_success(result)+ messages = get_topic_messages(user_profile, stream, new_resolved_topic)+ self.assert_length(messages, 6)+ self.assertEqual(+ messages[4].content,+ f"@_**{user_profile.full_name}|{user_profile.id}** has marked this topic as resolved.",+ )+ self.assertEqual(+ messages[5].content,+ f"This topic was moved here from #**public stream>{new_topic}** by @_**{user_profile.full_name}|{user_profile.id}**.",+ )+def parameterized_test_move_message_involving_private_stream(self,from_invite_only: bool,