mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
edit_history: Store additional fields on edit history events.
We modify the message_edit_history marshalling code so that this commit does not change the API, since we haven't backfilled the data yet. FormattedEditHistoryEvent, introduced in the previous commit, doesn't directly inherit fields from EditHistoryEvent, so no changes are required there.
This commit is contained in:
@@ -38,7 +38,12 @@ from zerver.lib.streams import get_web_public_streams_queryset
|
||||
from zerver.lib.timestamp import datetime_to_timestamp
|
||||
from zerver.lib.topic import DB_TOPIC_NAME, MESSAGE__TOPIC, TOPIC_LINKS, TOPIC_NAME
|
||||
from zerver.lib.topic_mutes import build_topic_mute_checker, topic_is_muted
|
||||
from zerver.lib.types import DisplayRecipientT, EditHistoryEvent, UserDisplayRecipient
|
||||
from zerver.lib.types import (
|
||||
APIEditHistoryEvent,
|
||||
DisplayRecipientT,
|
||||
EditHistoryEvent,
|
||||
UserDisplayRecipient,
|
||||
)
|
||||
from zerver.models import (
|
||||
MAX_TOPIC_NAME_LENGTH,
|
||||
Message,
|
||||
@@ -502,8 +507,17 @@ class MessageDict:
|
||||
if last_edit_time is not None:
|
||||
obj["last_edit_timestamp"] = datetime_to_timestamp(last_edit_time)
|
||||
assert edit_history_json is not None
|
||||
# Here we assume EditHistoryEvent == APIEditHistoryEvent
|
||||
edit_history: List[EditHistoryEvent] = orjson.loads(edit_history_json)
|
||||
raw_edit_history: List[EditHistoryEvent] = orjson.loads(edit_history_json)
|
||||
edit_history: List[APIEditHistoryEvent] = []
|
||||
for edit_history_event in raw_edit_history:
|
||||
# Drop fields we're not yet ready to have appear in the API
|
||||
if "prev_topic" in edit_history_event:
|
||||
del edit_history_event["prev_topic"]
|
||||
if "stream" in edit_history_event:
|
||||
del edit_history_event["stream"]
|
||||
if "topic" in edit_history_event:
|
||||
del edit_history_event["topic"]
|
||||
edit_history.append(edit_history_event)
|
||||
obj["edit_history"] = edit_history
|
||||
|
||||
if Message.need_to_render_content(
|
||||
|
||||
Reference in New Issue
Block a user