mirror of
https://github.com/zulip/zulip.git
synced 2025-10-31 20:13:46 +00:00
move_stream: Trigger only move notification.
This commit updates the code so that only the moved notification is triggered when moving a message between a resolved and unresolved topic in different streams or when moving a topic itself. This change takes place even when both stream change and resolve or unresolve a topic takes place in the same API request, as we now consider it only a move operation. This fixes a case where a message is moved between topics that have the same name, but one resolved and another unresolved and in different streams. Previously a resolved or unresolved notification would also be sent. Now, this will not happen, ensuring only the move operation is notified. Fixes part of #29007.
This commit is contained in:
committed by
Tim Abbott
parent
8236ed8205
commit
f4ca8025da
@@ -1039,20 +1039,12 @@ def do_update_message(
|
||||
|
||||
resolved_topic_message_id = None
|
||||
resolved_topic_message_deleted = False
|
||||
if topic_name is not None and content is None:
|
||||
# When stream is changed and topic is marked as resolved or unresolved
|
||||
# in the same API request, resolved or unresolved notification should
|
||||
# be sent to "new_stream".
|
||||
# In general, it is sent to "stream_being_edited".
|
||||
stream_to_send_resolve_topic_notification = stream_being_edited
|
||||
if new_stream is not None:
|
||||
stream_to_send_resolve_topic_notification = new_stream
|
||||
|
||||
assert stream_to_send_resolve_topic_notification is not None
|
||||
if topic_name is not None and content is None and new_stream is None:
|
||||
assert stream_being_edited is not None
|
||||
resolved_topic_message_id, resolved_topic_message_deleted = (
|
||||
maybe_send_resolve_topic_notifications(
|
||||
user_profile=user_profile,
|
||||
stream=stream_to_send_resolve_topic_notification,
|
||||
stream=stream_being_edited,
|
||||
old_topic_name=orig_topic_name,
|
||||
new_topic_name=topic_name,
|
||||
changed_messages=changed_messages,
|
||||
|
||||
@@ -1441,13 +1441,9 @@ class MessageMoveStreamTest(ZulipTestCase):
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
messages = get_topic_messages(user_profile, new_stream, new_topic_name)
|
||||
self.assert_length(messages, 5)
|
||||
self.assert_length(messages, 4)
|
||||
self.assertEqual(
|
||||
messages[3].content,
|
||||
f"@_**{user_profile.full_name}|{user_profile.id}** has marked this topic as resolved.",
|
||||
)
|
||||
self.assertEqual(
|
||||
messages[4].content,
|
||||
f"This topic was moved here from #**{first_stream.name}>test** by @_**{user_profile.full_name}|{user_profile.id}**.",
|
||||
)
|
||||
|
||||
@@ -1464,13 +1460,9 @@ class MessageMoveStreamTest(ZulipTestCase):
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
messages = get_topic_messages(user_profile, new_stream, new_topic_name)
|
||||
self.assert_length(messages, 7)
|
||||
self.assert_length(messages, 5)
|
||||
self.assertEqual(
|
||||
messages[5].content,
|
||||
f"@_**{user_profile.full_name}|{user_profile.id}** has marked this topic as unresolved.",
|
||||
)
|
||||
self.assertEqual(
|
||||
messages[6].content,
|
||||
messages[4].content,
|
||||
f"This topic was moved here from #**{second_stream.name}>✔ test** by @_**{user_profile.full_name}|{user_profile.id}**.",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user