types: Add EditHistoryEvent and APIEditHistoryEvent types.

These types will help make iteration on this code easier.

Note that `user_id` can be null due to the fact that
edit history entries before March 2017 did not log
the user that made the edit, which was years after
supporting topic edits (discovered in test deployment
of migration on chat.zulip.org).

Co-authored-by: Lauryn Menard <lauryn.menard@gmail.com>
This commit is contained in:
Tim Abbott
2022-03-01 15:49:18 -08:00
parent 44e08c9289
commit f1e5ed91a1
5 changed files with 61 additions and 19 deletions

View File

@@ -89,3 +89,40 @@ class UnspecifiedValue:
"""
pass
class APIEditHistoryEvent(TypedDict, total=False):
"""Format of legacy edit history events in the API. Contains legacy
fields like LEGACY_PREV_TOPIC that we intend to remove from the
API eventually.
"""
# Commented fields are fields we plan to add.
user_id: Optional[int]
timestamp: int
prev_stream: int
# stream: int
prev_subject: str
# prev_topic: str
# topic: str
prev_content: str
prev_rendered_content: Optional[str]
prev_rendered_content_version: Optional[int]
class EditHistoryEvent(TypedDict, total=False):
"""
Database format for edit history events.
"""
# Commented fields are fields we plan to add.
user_id: Optional[int]
timestamp: int
prev_stream: int
# stream: int
prev_subject: str
# prev_topic: str
# topic: str
prev_content: str
prev_rendered_content: Optional[str]
prev_rendered_content_version: Optional[int]