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:
Pedro Almeida
2024-06-27 19:02:07 +01:00
committed by Tim Abbott
parent 8236ed8205
commit f4ca8025da
2 changed files with 6 additions and 22 deletions

View File

@@ -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,