Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_edit: Extract update_edit_history.
Aman Agrawalde50f4ae25d7
diff --git a/zerver/lib/topic.py b/zerver/lib/topic.pyindex 9fc33ed55c9..99588314afc 100644--- a/zerver/lib/topic.py+++ b/zerver/lib/topic.py@@ -126,6 +126,18 @@ def user_message_exists_for_topic().exists()+def update_edit_history(+ message: Message, last_edit_time: datetime, edit_history_event: Dict[str, Any]+) -> None:+ message.last_edit_time = last_edit_time+ if message.edit_history is not None:+ edit_history = orjson.loads(message.edit_history)+ edit_history.insert(0, edit_history_event)+ else:+ edit_history = [edit_history_event]+ message.edit_history = orjson.dumps(edit_history).decode()++def update_messages_for_topic_edit(edited_message: Message,propagate_mode: str,@@ -170,13 +182,7 @@ def update_messages_for_topic_edit(m.set_topic_name(topic_name)for message in messages_list:- message.last_edit_time = last_edit_time- if message.edit_history is not None:- edit_history = orjson.loads(message.edit_history)- edit_history.insert(0, edit_history_event)- else:- edit_history = [edit_history_event]- message.edit_history = orjson.dumps(edit_history).decode()+ update_edit_history(message, last_edit_time, edit_history_event)Message.objects.bulk_update(messages_list, update_fields)