mirror of https://github.com/zulip/zulip.git
Fix "prev_subject" with LEGACY_PREV_TOPIC.
I added `LEGACY_` prefix to the var, because otherwise you'd have really confusing code where you change the key from `PREV_TOPIC` to "prev_topic".
This commit is contained in:
parent
a49ba8c577
commit
0a171bf9bf
|
@ -61,7 +61,7 @@ from zerver.lib.topic import (
|
|||
save_message_for_edit_use_case,
|
||||
update_messages_for_topic_edit,
|
||||
ORIG_TOPIC,
|
||||
PREV_TOPIC,
|
||||
LEGACY_PREV_TOPIC,
|
||||
TOPIC_LINKS,
|
||||
TOPIC_NAME,
|
||||
)
|
||||
|
@ -3968,7 +3968,7 @@ def do_update_message(user_profile: UserProfile, message: Message, topic_name: O
|
|||
event[ORIG_TOPIC] = orig_topic_name
|
||||
event[TOPIC_NAME] = topic_name
|
||||
event[TOPIC_LINKS] = bugdown.topic_links(message.sender.realm_id, topic_name)
|
||||
edit_history_event[PREV_TOPIC] = orig_topic_name
|
||||
edit_history_event[LEGACY_PREV_TOPIC] = orig_topic_name
|
||||
|
||||
if propagate_mode in ["change_later", "change_all"]:
|
||||
messages_list = update_messages_for_topic_edit(
|
||||
|
|
|
@ -23,9 +23,14 @@ from typing import Any, Dict, List, Tuple
|
|||
ORIG_TOPIC = "orig_subject"
|
||||
TOPIC_NAME = "subject"
|
||||
TOPIC_LINKS = "subject_links"
|
||||
PREV_TOPIC = "prev_subject"
|
||||
MATCH_TOPIC = "match_subject"
|
||||
|
||||
# This constant is actually embedded into
|
||||
# the JSON data for message edit history,
|
||||
# so we'll always need to handle legacy data
|
||||
# unless we do a pretty tricky migration.
|
||||
LEGACY_PREV_TOPIC = "prev_subject"
|
||||
|
||||
# This is used in low-level message functions in
|
||||
# zerver/lib/message.py, and it's not user facing.
|
||||
DB_TOPIC_NAME = "subject"
|
||||
|
|
|
@ -38,6 +38,7 @@ from zerver.lib.topic import (
|
|||
topic_match_sa,
|
||||
user_message_exists_for_topic,
|
||||
DB_TOPIC_NAME,
|
||||
LEGACY_PREV_TOPIC,
|
||||
MATCH_TOPIC,
|
||||
)
|
||||
from zerver.lib.topic_mutes import exclude_topic_mutes
|
||||
|
@ -1299,11 +1300,10 @@ def fill_edit_history_entries(message_history: List[Dict[str, Any]], message: Me
|
|||
|
||||
for entry in message_history:
|
||||
entry['topic'] = prev_topic
|
||||
if 'prev_subject' in entry:
|
||||
# We replace use of 'subject' with 'topic' for downstream simplicity
|
||||
prev_topic = entry['prev_subject']
|
||||
if LEGACY_PREV_TOPIC in entry:
|
||||
prev_topic = entry[LEGACY_PREV_TOPIC]
|
||||
entry['prev_topic'] = prev_topic
|
||||
del entry['prev_subject']
|
||||
del entry[LEGACY_PREV_TOPIC]
|
||||
|
||||
entry['content'] = prev_content
|
||||
entry['rendered_content'] = prev_rendered_content
|
||||
|
|
Loading…
Reference in New Issue