mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 11:52:01 +00:00
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:
@@ -8,6 +8,7 @@ from sqlalchemy.sql import ColumnElement, column, func, literal
|
||||
from sqlalchemy.types import Boolean, Text
|
||||
|
||||
from zerver.lib.request import REQ
|
||||
from zerver.lib.types import EditHistoryEvent
|
||||
from zerver.models import Message, Stream, UserMessage, UserProfile
|
||||
|
||||
# Only use these constants for events.
|
||||
@@ -135,11 +136,11 @@ def user_message_exists_for_topic(
|
||||
|
||||
|
||||
def update_edit_history(
|
||||
message: Message, last_edit_time: datetime, edit_history_event: Dict[str, Any]
|
||||
message: Message, last_edit_time: datetime, edit_history_event: EditHistoryEvent
|
||||
) -> None:
|
||||
message.last_edit_time = last_edit_time
|
||||
if message.edit_history is not None:
|
||||
edit_history = orjson.loads(message.edit_history)
|
||||
edit_history: List[EditHistoryEvent] = orjson.loads(message.edit_history)
|
||||
edit_history.insert(0, edit_history_event)
|
||||
else:
|
||||
edit_history = [edit_history_event]
|
||||
@@ -154,7 +155,7 @@ def update_messages_for_topic_edit(
|
||||
topic_name: Optional[str],
|
||||
new_stream: Optional[Stream],
|
||||
old_stream: Stream,
|
||||
edit_history_event: Dict[str, Any],
|
||||
edit_history_event: EditHistoryEvent,
|
||||
last_edit_time: datetime,
|
||||
) -> List[Message]:
|
||||
propagate_query = Q(recipient_id=old_stream.recipient_id, subject__iexact=orig_topic_name)
|
||||
|
||||
Reference in New Issue
Block a user