mirror of https://github.com/zulip/zulip.git
typing: Add support for empty topic name.
This commit is contained in:
parent
54499fc6e2
commit
95742c8f03
|
@ -1618,6 +1618,18 @@ def process_user_topic_event(event: Mapping[str, Any], users: Iterable[int]) ->
|
||||||
client.add_event(event)
|
client.add_event(event)
|
||||||
|
|
||||||
|
|
||||||
|
def process_stream_typing_notification_event(event: Mapping[str, Any], users: Iterable[int]) -> None:
|
||||||
|
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 event.get("topic") == "" and not client.empty_topic_name:
|
||||||
|
event["topic"] = "general chat"
|
||||||
|
|
||||||
|
client.add_event(event)
|
||||||
|
|
||||||
|
|
||||||
def process_notification(notice: Mapping[str, Any]) -> None:
|
def process_notification(notice: Mapping[str, Any]) -> None:
|
||||||
event: Mapping[str, Any] = notice["event"]
|
event: Mapping[str, Any] = notice["event"]
|
||||||
users: list[int] | list[Mapping[str, Any]] = notice["users"]
|
users: list[int] | list[Mapping[str, Any]] = notice["users"]
|
||||||
|
@ -1648,6 +1660,8 @@ def process_notification(notice: Mapping[str, Any]) -> None:
|
||||||
process_user_group_name_update_event(event, cast(list[int], users))
|
process_user_group_name_update_event(event, cast(list[int], users))
|
||||||
elif event["type"] == "user_topic":
|
elif event["type"] == "user_topic":
|
||||||
process_user_topic_event(event, cast(list[int], users))
|
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":
|
elif event["type"] == "cleanup_queue":
|
||||||
# cleanup_event_queue may generate this event to forward cleanup
|
# cleanup_event_queue may generate this event to forward cleanup
|
||||||
# requests to the right shard.
|
# requests to the right shard.
|
||||||
|
|
|
@ -8,6 +8,7 @@ from zerver.actions.typing import check_send_typing_notification, do_send_stream
|
||||||
from zerver.lib.exceptions import JsonableError
|
from zerver.lib.exceptions import JsonableError
|
||||||
from zerver.lib.response import json_success
|
from zerver.lib.response import json_success
|
||||||
from zerver.lib.streams import access_stream_by_id, access_stream_for_send_message
|
from zerver.lib.streams import access_stream_by_id, access_stream_for_send_message
|
||||||
|
from zerver.lib.topic import maybe_rename_general_chat_to_empty_topic
|
||||||
from zerver.lib.typed_endpoint import ApiParamConfig, OptionalTopic, typed_endpoint
|
from zerver.lib.typed_endpoint import ApiParamConfig, OptionalTopic, typed_endpoint
|
||||||
from zerver.models import UserProfile
|
from zerver.models import UserProfile
|
||||||
|
|
||||||
|
@ -44,6 +45,7 @@ def send_notification_backend(
|
||||||
# permission to send messages to it.
|
# permission to send messages to it.
|
||||||
stream = access_stream_by_id(user_profile, stream_id)[0]
|
stream = access_stream_by_id(user_profile, stream_id)[0]
|
||||||
access_stream_for_send_message(user_profile, stream, forwarder_user_profile=None)
|
access_stream_for_send_message(user_profile, stream, forwarder_user_profile=None)
|
||||||
|
topic = maybe_rename_general_chat_to_empty_topic(topic)
|
||||||
do_send_stream_typing_notification(user_profile, operator, stream, topic)
|
do_send_stream_typing_notification(user_profile, operator, stream, topic)
|
||||||
else:
|
else:
|
||||||
if notification_to is None:
|
if notification_to is None:
|
||||||
|
|
Loading…
Reference in New Issue