Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_edit: Pass old_stream to update_messages_for_topic_edit.

Tim Abbott7ef0d21fc292
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index aa2e0cb25ef..68ee76ea522 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -5791,7 +5791,6 @@ def do_update_message(
event["propagate_mode"] = propagate_mode
event["stream_id"] = target_message.recipient.type_id
- old_recipient_id = None
if new_stream is not None:
assert content is None
assert target_message.is_stream_message()
@@ -5799,7 +5798,6 @@ def do_update_message(
edit_history_event["prev_stream"] = stream_being_edited.id
event[ORIG_TOPIC] = orig_topic_name
- old_recipient_id = target_message.recipient_id
target_message.recipient_id = new_stream.recipient_id
event["new_stream_id"] = new_stream.id
@@ -5864,6 +5862,8 @@ def do_update_message(
delete_event_notify_user_ids: List[int] = []
if propagate_mode in ["change_later", "change_all"]:
assert topic_name is not None or new_stream is not None
+ assert stream_being_edited is not None
+
# Other messages should only get topic/stream fields in their edit history.
topic_only_edit_history_event = {
k: v
@@ -5883,7 +5883,7 @@ def do_update_message(
orig_topic_name=orig_topic_name,
topic_name=topic_name,
new_stream=new_stream,
- old_recipient_id=old_recipient_id,
+ old_stream=stream_being_edited,
edit_history_event=topic_only_edit_history_event,
last_edit_time=timestamp,
)
diff --git a/zerver/lib/topic.py b/zerver/lib/topic.py
index a0ce4d5b233..9ea27a5ab1f 100644
--- a/zerver/lib/topic.py
+++ b/zerver/lib/topic.py
@@ -145,18 +145,11 @@ def update_messages_for_topic_edit(
orig_topic_name: str,
topic_name: Optional[str],
new_stream: Optional[Stream],
- old_recipient_id: Optional[int],
+ old_stream: Stream,
edit_history_event: Dict[str, Any],
last_edit_time: datetime,
) -> List[Message]:
- assert (new_stream and old_recipient_id) or (not new_stream and not old_recipient_id)
-
- if old_recipient_id is not None:
- recipient_id = old_recipient_id
- else:
- recipient_id = edited_message.recipient_id
-
- propagate_query = Q(recipient_id=recipient_id, subject__iexact=orig_topic_name)
+ propagate_query = Q(recipient_id=old_stream.recipient_id, subject__iexact=orig_topic_name)
if propagate_mode == "change_all":
propagate_query = propagate_query & ~Q(id=edited_message.id)
if propagate_mode == "change_later":