mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
typing: Add support for empty topic name.
This commit is a part of the work to support empty string as a topic name. Previously, empty string was not a valid topic name. Now, typing operation supports empty topic name. Adds backward compatibility for: - `topic` field in the `typing` event type
This commit is contained in:
committed by
Tim Abbott
parent
27e95f7d33
commit
01f749c0b8
@@ -1642,6 +1642,27 @@ def process_user_topic_event(event: Mapping[str, Any], users: Iterable[int]) ->
|
||||
client.add_event(empty_topic_name_fallback_event)
|
||||
|
||||
|
||||
def process_stream_typing_notification_event(
|
||||
event: Mapping[str, Any], users: Iterable[int]
|
||||
) -> None:
|
||||
empty_topic_name_fallback_event: Mapping[str, Any] | dict[str, Any]
|
||||
if event.get("topic") == "":
|
||||
empty_topic_name_fallback_event = dict(event)
|
||||
empty_topic_name_fallback_event["topic"] = Message.EMPTY_TOPIC_FALLBACK_NAME
|
||||
else:
|
||||
empty_topic_name_fallback_event = event
|
||||
|
||||
for user_profile_id in users:
|
||||
for client in get_client_descriptors_for_user(user_profile_id):
|
||||
if not client.accepts_event(event):
|
||||
continue
|
||||
|
||||
if client.empty_topic_name:
|
||||
client.add_event(event)
|
||||
else:
|
||||
client.add_event(empty_topic_name_fallback_event)
|
||||
|
||||
|
||||
def process_notification(notice: Mapping[str, Any]) -> None:
|
||||
event: Mapping[str, Any] = notice["event"]
|
||||
users: list[int] | list[Mapping[str, Any]] = notice["users"]
|
||||
@@ -1672,6 +1693,8 @@ def process_notification(notice: Mapping[str, Any]) -> None:
|
||||
process_user_group_name_update_event(event, cast(list[int], users))
|
||||
elif event["type"] == "user_topic":
|
||||
process_user_topic_event(event, cast(list[int], users))
|
||||
elif event["type"] == "typing" and event["message_type"] == "stream":
|
||||
process_stream_typing_notification_event(event, cast(list[int], users))
|
||||
elif event["type"] == "cleanup_queue":
|
||||
# cleanup_event_queue may generate this event to forward cleanup
|
||||
# requests to the right shard.
|
||||
|
||||
Reference in New Issue
Block a user