Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Do not prefetch group settings using select_related.
Sahil Batra5bbb39a06cbd
diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.pyindex 35845e7a4b0..bedb6ddd64c 100644--- a/zerver/actions/message_edit.py+++ b/zerver/actions/message_edit.py@@ -54,7 +54,6 @@ from zerver.lib.stream_subscription import get_active_subscriptions_for_stream_ifrom zerver.lib.stream_topic import StreamTopicTargetfrom zerver.lib.streams import (access_stream_by_id,- access_stream_by_id_for_message,can_access_stream_history,can_edit_topic,can_move_messages_out_of_channel,@@ -83,6 +82,7 @@ from zerver.lib.topic import (from zerver.lib.topic_link_util import get_stream_topic_link_syntaxfrom zerver.lib.types import DirectMessageEditRequest, EditHistoryEvent, StreamMessageEditRequestfrom zerver.lib.url_encoding import stream_message_url+from zerver.lib.user_groups import get_recursive_membership_groupsfrom zerver.lib.user_message import bulk_insert_all_umsfrom zerver.lib.user_topics import get_users_with_user_topic_visibility_policyfrom zerver.lib.widget import is_widget_message@@ -98,11 +98,8 @@ from zerver.models import (UserProfile,UserTopic,)-from zerver.models.streams import (- StreamTopicsPolicyEnum,- get_stream_by_id_for_sending_message,- get_stream_by_id_in_realm,-)+from zerver.models.groups import get_realm_system_groups_name_dict+from zerver.models.streams import StreamTopicsPolicyEnum, get_stream_by_id_in_realmfrom zerver.models.users import ResolvedTopicNoticeAutoReadPolicyEnum, get_system_botfrom zerver.tornado.django_api import send_event_on_commit@@ -1496,15 +1493,12 @@ def build_message_edit_request()orig_stream_id = message.recipient.type_id- # We call get_stream_by_id_for_sending_message instead of- # get_stream_by_id_in_realm here so that "can_create_topic_group" is- # fetched using select_related and we can save a couple of DB queries.- orig_stream = get_stream_by_id_for_sending_message(orig_stream_id, message.realm)+ orig_stream = get_stream_by_id_in_realm(orig_stream_id, message.realm)is_stream_edited = Falsetarget_stream = orig_streamif stream_id is not None:- target_stream = access_stream_by_id_for_message(user_profile, stream_id)[0]+ target_stream = access_stream_by_id(user_profile, stream_id)[0]is_stream_edited = Truetopics_policy = get_stream_topics_policy(message.realm, target_stream)@@ -1664,13 +1658,20 @@ def check_update_message(check_user_group_mention_allowed(user_profile, mentioned_group_ids)if isinstance(message_edit_request, StreamMessageEditRequest):+ user_recursive_group_ids = set(+ get_recursive_membership_groups(user_profile).values_list("id", flat=True)+ )+ system_groups_name_dict = get_realm_system_groups_name_dict(user_profile.realm_id)if message_edit_request.is_stream_edited:assert message.is_channel_messageif not can_move_messages_out_of_channel(user_profile, message_edit_request.orig_stream):raise JsonableError(_("You don't have permission to move this message"))check_stream_access_based_on_can_send_message_group(- user_profile, message_edit_request.target_stream+ user_profile,+ message_edit_request.target_stream,+ user_recursive_group_ids,+ system_groups_name_dict,)if (@@ -1706,6 +1707,8 @@ def check_update_message(user_profile,message_edit_request.target_stream,message_edit_request.target_topic_name,+ user_recursive_group_ids,+ system_groups_name_dict,)updated_message_result = do_update_message(diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.pyindex b106742d94e..7b6b21ae1d6 100644--- a/zerver/actions/message_send.py+++ b/zerver/actions/message_send.py@@ -86,6 +86,7 @@ from zerver.lib.url_preview.types import UrlEmbedDatafrom zerver.lib.user_groups import (check_any_user_has_permission_by_role,check_user_has_permission_by_role,+ get_recursive_membership_groups,is_any_user_in_group,is_user_in_group,)@@ -119,8 +120,8 @@ from zerver.models.recipients import get_direct_message_group_user_idsfrom zerver.models.scheduled_jobs import NotificationTriggersfrom zerver.models.streams import (StreamTopicsPolicyEnum,- get_stream_by_id_for_sending_message,- get_stream_by_name_for_sending_message,+ get_realm_stream,+ get_stream_by_id_in_realm,)from zerver.models.users import get_system_bot, get_user_by_delivery_email, is_cross_realm_bot_emailfrom zerver.tornado.django_api import send_event_on_commit@@ -1574,7 +1575,7 @@ def validate_stream_name_with_pm_notification(check_stream_name(stream_name)try:- stream = get_stream_by_name_for_sending_message(stream_name, realm)+ stream = get_realm_stream(stream_name, realm.id)send_pm_if_empty_stream(stream, realm, sender)except Stream.DoesNotExist:send_pm_if_empty_stream(None, realm, sender, stream_name=stream_name)@@ -1587,7 +1588,7 @@ def validate_stream_id_with_pm_notification(stream_id: int, realm: Realm, sender: UserProfile) -> Stream:try:- stream = get_stream_by_id_for_sending_message(stream_id, realm)+ stream = get_stream_by_id_in_realm(stream_id, realm)send_pm_if_empty_stream(stream, realm, sender)except Stream.DoesNotExist:send_pm_if_empty_stream(None, realm, sender, stream_id=stream_id)@@ -1787,12 +1788,18 @@ def check_message(type=Recipient.STREAM,)+ user_recursive_group_ids = set(+ get_recursive_membership_groups(sender).values_list("id", flat=True)+ )+ system_groups_name_dict = get_realm_system_groups_name_dict(stream.realm_id)if not skip_stream_access_check:access_stream_for_send_message(sender=sender,stream=stream,forwarder_user_profile=forwarder_user_profile,archived_channel_notice=archived_channel_notice,+ user_recursive_group_ids=user_recursive_group_ids,+ system_groups_name_dict=system_groups_name_dict,)else:# Defensive assertion - the only currently supported use case@@ -1802,7 +1809,11 @@ def check_message(assert sender.bot_type == sender.OUTGOING_WEBHOOK_BOTcheck_for_can_create_topic_group_violation(- user_profile=sender, stream=stream, topic_name=topic_name+ user_profile=sender,+ stream=stream,+ topic_name=topic_name,+ user_recursive_group_ids=user_recursive_group_ids,+ system_groups_name_dict=system_groups_name_dict,)topics_policy = get_stream_topics_policy(realm, stream)diff --git a/zerver/lib/streams.py b/zerver/lib/streams.pyindex dfe43911456..24ed7e51060 100644--- a/zerver/lib/streams.py+++ b/zerver/lib/streams.py@@ -53,14 +53,13 @@ from zerver.models import (UserGroupMembership,UserProfile,)-from zerver.models.groups import SystemGroups+from zerver.models.groups import SystemGroups, get_realm_system_groups_name_dictfrom zerver.models.realm_audit_logs import AuditLogEventTypefrom zerver.models.streams import (StreamTopicsPolicyEnum,bulk_get_streams,get_realm_stream,get_stream,- get_stream_by_id_for_sending_message,get_stream_by_id_in_realm,)from zerver.models.users import active_non_guest_user_ids, active_user_ids, is_cross_realm_bot_email@@ -594,25 +593,21 @@ def is_user_in_can_remove_subscribers_group(def check_stream_access_based_on_can_send_message_group(- sender: UserProfile, stream: Stream+ sender: UserProfile,+ stream: Stream,+ user_recursive_group_ids: set[int],+ system_groups_name_dict: dict[int, str],) -> None:if is_cross_realm_bot_email(sender.delivery_email):return- can_send_message_group = stream.can_send_message_group- if hasattr(can_send_message_group, "named_user_group"):- if can_send_message_group.named_user_group.name == SystemGroups.EVERYONE:- return-- if can_send_message_group.named_user_group.name == SystemGroups.NOBODY:- raise JsonableError(_("You do not have permission to post in this channel."))-- if not user_has_permission_for_group_setting(- stream.can_send_message_group_id,- sender,- Stream.stream_permission_group_settings["can_send_message_group"],- direct_member_only=False,+ if (+ stream.can_send_message_group_id in system_groups_name_dict+ and system_groups_name_dict[stream.can_send_message_group_id] == SystemGroups.EVERYONE):+ return++ if stream.can_send_message_group_id not in user_recursive_group_ids:raise JsonableError(_("You do not have permission to post in this channel."))@@ -621,14 +616,31 @@ def access_stream_for_send_message(stream: Stream,forwarder_user_profile: UserProfile | None,archived_channel_notice: bool = False,+ user_recursive_group_ids: set[int] | None = None,+ system_groups_name_dict: dict[int, str] | None = None,) -> None:# Our caller is responsible for making sure that `stream` actually# matches the realm of the sender.+ if user_recursive_group_ids is None:+ user_recursive_group_ids = set(+ get_recursive_membership_groups(sender).values_list("id", flat=True)+ )++ if system_groups_name_dict is None:+ system_groups_name_dict = get_realm_system_groups_name_dict(stream.realm_id)+try:- check_stream_access_based_on_can_send_message_group(sender, stream)+ check_stream_access_based_on_can_send_message_group(+ sender, stream, user_recursive_group_ids, system_groups_name_dict+ )except JsonableError as e:if sender.is_bot and sender.bot_owner is not None:- check_stream_access_based_on_can_send_message_group(sender.bot_owner, stream)+ bot_owner_recursive_group_ids = set(+ get_recursive_membership_groups(sender.bot_owner).values_list("id", flat=True)+ )+ check_stream_access_based_on_can_send_message_group(+ sender.bot_owner, stream, bot_owner_recursive_group_ids, system_groups_name_dict+ )else:raise JsonableError(e.msg)@@ -682,10 +694,6 @@ def access_stream_for_send_message(# Bots can send to any stream their owner can.return- user_recursive_group_ids = set(- get_recursive_membership_groups(sender).values_list("id", flat=True)- )-if (stream.history_public_to_subscribersand is_user_in_groups_granting_content_access(stream, user_recursive_group_ids)@@ -699,49 +707,41 @@ def access_stream_for_send_message()-def check_user_can_create_new_topics(user_profile: UserProfile, stream: Stream) -> None:- can_create_topic_group = stream.can_create_topic_group- if (- hasattr(can_create_topic_group, "named_user_group")- and can_create_topic_group.named_user_group.name == SystemGroups.NOBODY- ):- raise JsonableError(_("You do not have permission to create new topics in this channel."))-- if not user_has_permission_for_group_setting(- stream.can_create_topic_group_id,- user_profile,- Stream.stream_permission_group_settings["can_create_topic_group"],- direct_member_only=False,- ):- raise JsonableError(_("You do not have permission to create new topics in this channel."))--def check_for_can_create_topic_group_violation(- user_profile: UserProfile, stream: Stream, topic_name: str+ user_profile: UserProfile,+ stream: Stream,+ topic_name: str,+ user_recursive_group_ids: set[int],+ system_groups_name_dict: dict[int, str],) -> None:if is_cross_realm_bot_email(user_profile.delivery_email):return- can_create_topic_group = stream.can_create_topic_groupif (- hasattr(can_create_topic_group, "named_user_group")- and can_create_topic_group.named_user_group.name == SystemGroups.EVERYONE+ stream.can_create_topic_group_id in system_groups_name_dict+ and system_groups_name_dict[stream.can_create_topic_group_id] == SystemGroups.EVERYONE):return+ if stream.can_create_topic_group_id in user_recursive_group_ids:+ return+assert stream.recipient_id is not Nonetopic_exists = messages_for_topic(realm_id=stream.realm_id, stream_recipient_id=stream.recipient_id, topic_name=topic_name).exists()- if not topic_exists:- try:- check_user_can_create_new_topics(user_profile, stream)- except JsonableError as e:- if user_profile.is_bot and user_profile.bot_owner is not None:- check_user_can_create_new_topics(user_profile.bot_owner, stream)- else:- raise JsonableError(e.msg)+ if topic_exists:+ return++ if user_profile.is_bot and user_profile.bot_owner is not None:+ bot_owner_recursive_group_ids = set(+ get_recursive_membership_groups(user_profile.bot_owner).values_list("id", flat=True)+ )+ if stream.can_create_topic_group_id in bot_owner_recursive_group_ids:+ return++ raise JsonableError(_("You do not have permission to create new topics in this channel."))def check_for_exactly_one_stream_arg(stream_id: int | None, stream: str | None) -> None:@@ -1012,33 +1012,6 @@ def access_stream_by_id(return (stream, sub)-def access_stream_by_id_for_message(- user_profile: UserProfile,- stream_id: int,- *,- require_active_channel: bool = True,- require_content_access: bool = True,-) -> tuple[Stream, Subscription | None]:- """- Variant of access_stream_by_id that uses get_stream_by_id_for_sending_message- to ensure we do a select_related("can_send_message_group", "can_create_topic_group").- """- error = _("Invalid channel ID")- try:- stream = get_stream_by_id_for_sending_message(stream_id, user_profile.realm)- except Stream.DoesNotExist:- raise JsonableError(error)-- sub = access_stream_common(- user_profile,- stream,- error,- require_active_channel=require_active_channel,- require_content_access=require_content_access,- )- return (stream, sub)--def get_public_streams_queryset(realm: Realm) -> QuerySet[Stream]:return Stream.objects.filter(realm=realm, invite_only=False, history_public_to_subscribers=True)diff --git a/zerver/models/streams.py b/zerver/models/streams.pyindex 128cec31e8f..eebe4a13d70 100644--- a/zerver/models/streams.py+++ b/zerver/models/streams.py@@ -332,26 +332,6 @@ def get_stream_by_id_in_realm(stream_id: int, realm: Realm) -> Stream:return Stream.objects.select_related("realm", "recipient").get(id=stream_id, realm=realm)-def get_stream_by_name_for_sending_message(stream_name: str, realm: Realm) -> Stream:- return Stream.objects.select_related(- "can_send_message_group",- "can_send_message_group__named_user_group",- "can_create_topic_group",- "can_create_topic_group__named_user_group",- ).get(name__iexact=stream_name.strip(), realm_id=realm.id)---def get_stream_by_id_for_sending_message(stream_id: int, realm: Realm) -> Stream:- return Stream.objects.select_related(- "realm",- "recipient",- "can_send_message_group",- "can_send_message_group__named_user_group",- "can_create_topic_group",- "can_create_topic_group__named_user_group",- ).get(id=stream_id, realm=realm)--def bulk_get_streams(realm: Realm, stream_names: set[str]) -> dict[str, Any]:def fetch_streams_by_name(stream_names: set[str]) -> QuerySet[Stream]:#diff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.pyindex fd40b9193b9..9a860059d76 100644--- a/zerver/tests/test_email_mirror.py+++ b/zerver/tests/test_email_mirror.py@@ -1401,7 +1401,7 @@ class TestMissedMessageEmailMessages(ZulipTestCase):incoming_valid_message["To"] = mm_addressincoming_valid_message["Reply-to"] = user_profile.delivery_email- with self.assert_database_query_count(18):+ with self.assert_database_query_count(19):process_message(incoming_valid_message)# confirm that Hamlet got the messagediff --git a/zerver/tests/test_message_move_stream.py b/zerver/tests/test_message_move_stream.pyindex 8d62c0efa86..8089eeb6503 100644--- a/zerver/tests/test_message_move_stream.py+++ b/zerver/tests/test_message_move_stream.py@@ -1563,7 +1563,7 @@ class MessageMoveStreamTest(ZulipTestCase):"iago", "test move stream", "new stream", "test")- with self.assert_database_query_count(59), self.assert_memcached_count(14):+ with self.assert_database_query_count(63), self.assert_memcached_count(17):result = self.client_patch(f"/json/messages/{msg_id}",{diff --git a/zerver/tests/test_message_move_topic.py b/zerver/tests/test_message_move_topic.pyindex 6d8c905ebd5..bd851537e64 100644--- a/zerver/tests/test_message_move_topic.py+++ b/zerver/tests/test_message_move_topic.py@@ -420,7 +420,7 @@ class MessageMoveTopicTest(ZulipTestCase):# state + 1/user with a UserTopic row for the events data)# beyond what is typical were there not UserTopic records to# update. Ideally, we'd eliminate the per-user component.- with self.assert_database_query_count(27):+ with self.assert_database_query_count(29):check_update_message(user_profile=hamlet,message_id=message_id,@@ -517,7 +517,7 @@ class MessageMoveTopicTest(ZulipTestCase):set_topic_visibility_policy(desdemona, muted_topics, UserTopic.VisibilityPolicy.MUTED)set_topic_visibility_policy(cordelia, muted_topics, UserTopic.VisibilityPolicy.MUTED)- with self.assert_database_query_count(29):+ with self.assert_database_query_count(31):check_update_message(user_profile=desdemona,message_id=message_id,@@ -547,7 +547,7 @@ class MessageMoveTopicTest(ZulipTestCase):]set_topic_visibility_policy(desdemona, muted_topics, UserTopic.VisibilityPolicy.MUTED)set_topic_visibility_policy(cordelia, muted_topics, UserTopic.VisibilityPolicy.MUTED)- with self.assert_database_query_count(35):+ with self.assert_database_query_count(37):check_update_message(user_profile=desdemona,message_id=message_id,@@ -580,7 +580,7 @@ class MessageMoveTopicTest(ZulipTestCase):set_topic_visibility_policy(desdemona, muted_topics, UserTopic.VisibilityPolicy.MUTED)set_topic_visibility_policy(cordelia, muted_topics, UserTopic.VisibilityPolicy.MUTED)- with self.assert_database_query_count(31):+ with self.assert_database_query_count(33):check_update_message(user_profile=desdemona,message_id=message_id,@@ -603,7 +603,7 @@ class MessageMoveTopicTest(ZulipTestCase):second_message_id = self.send_stream_message(hamlet, stream_name, topic_name="changed topic name", content="Second message")- with self.assert_database_query_count(25):+ with self.assert_database_query_count(27):check_update_message(user_profile=desdemona,message_id=second_message_id,@@ -682,7 +682,7 @@ class MessageMoveTopicTest(ZulipTestCase):users_to_be_notified_via_muted_topics_event.append(user_topic.user_profile_id)change_all_topic_name = "Topic 1 edited"- with self.assert_database_query_count(32):+ with self.assert_database_query_count(34):check_update_message(user_profile=hamlet,message_id=message_id,diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.pyindex 2f2b6905379..43563ccc604 100644--- a/zerver/tests/test_message_send.py+++ b/zerver/tests/test_message_send.py@@ -1786,7 +1786,7 @@ class StreamMessagesTest(ZulipTestCase):setting_value=UserProfile.AUTOMATICALLY_CHANGE_VISIBILITY_POLICY_NEVER,acting_user=None,)- with self.assert_database_query_count(14):+ with self.assert_database_query_count(15):check_send_stream_message(sender=sender,client=sending_client,@@ -1806,7 +1806,7 @@ class StreamMessagesTest(ZulipTestCase):# 5 queries: 1 to check if it is the first message in the topic +# 1 to check if the topic is already followed + 3 to follow the topic.flush_per_request_caches()- with self.assert_database_query_count(19):+ with self.assert_database_query_count(20):check_send_stream_message(sender=sender,client=sending_client,@@ -1826,7 +1826,7 @@ class StreamMessagesTest(ZulipTestCase):# a message to a topic with visibility policy other than FOLLOWED.# 1 to check if the topic is already followed + 3 queries to follow the topic.flush_per_request_caches()- with self.assert_database_query_count(18):+ with self.assert_database_query_count(19):check_send_stream_message(sender=sender,client=sending_client,@@ -1837,7 +1837,7 @@ class StreamMessagesTest(ZulipTestCase):# If the topic is already FOLLOWED, there will be an increase in the query# count of 1 to check if the topic is already followed.flush_per_request_caches()- with self.assert_database_query_count(15):+ with self.assert_database_query_count(16):check_send_stream_message(sender=sender,client=sending_client,@@ -1862,7 +1862,7 @@ class StreamMessagesTest(ZulipTestCase):# 1 to get the user_id of the mentioned user + 1 to check if the topic# is already followed + 3 queries to follow the topic.flush_per_request_caches()- with self.assert_database_query_count(23):+ with self.assert_database_query_count(24):check_send_stream_message(sender=sender,client=sending_client,@@ -1875,7 +1875,7 @@ class StreamMessagesTest(ZulipTestCase):# 1 to get the user_id of the mentioned user + 1 to check if the topic is# already followed.flush_per_request_caches()- with self.assert_database_query_count(20):+ with self.assert_database_query_count(21):check_send_stream_message(sender=sender,client=sending_client,@@ -1885,7 +1885,7 @@ class StreamMessagesTest(ZulipTestCase):)flush_per_request_caches()- with self.assert_database_query_count(17):+ with self.assert_database_query_count(18):check_send_stream_message(sender=sender,client=sending_client,diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.pyindex 0e83d92c36e..d06eb26e55d 100644--- a/zerver/tests/test_subs.py+++ b/zerver/tests/test_subs.py@@ -4041,7 +4041,7 @@ class SubscriptionAPITest(ZulipTestCase):streams_to_sub = ["multi_user_stream"]with (self.capture_send_event_calls(expected_num_events=5) as events,- self.assert_database_query_count(44),+ self.assert_database_query_count(45),):self.subscribe_via_post(self.test_user,@@ -4950,7 +4950,7 @@ class SubscriptionAPITest(ZulipTestCase):]# Test creating a public stream when realm does not have a notification stream.- with self.assert_database_query_count(44):+ with self.assert_database_query_count(45):self.subscribe_via_post(self.test_user,[new_streams[0]],@@ -4958,7 +4958,7 @@ class SubscriptionAPITest(ZulipTestCase):)# Test creating private stream.- with self.assert_database_query_count(52):+ with self.assert_database_query_count(53):self.subscribe_via_post(self.test_user,[new_streams[1]],@@ -4970,7 +4970,7 @@ class SubscriptionAPITest(ZulipTestCase):new_stream_announcements_stream = get_stream(self.streams[0], self.test_realm)self.test_realm.new_stream_announcements_stream_id = new_stream_announcements_stream.idself.test_realm.save()- with self.assert_database_query_count(56):+ with self.assert_database_query_count(58):self.subscribe_via_post(self.test_user,[new_streams[2]],diff --git a/zerver/tests/test_typing.py b/zerver/tests/test_typing.pyindex bfebc76e998..93678d185d0 100644--- a/zerver/tests/test_typing.py+++ b/zerver/tests/test_typing.py@@ -481,7 +481,7 @@ class TypingHappyPathTestStreams(ZulipTestCase):)with (- self.assert_database_query_count(6),+ self.assert_database_query_count(8),self.capture_send_event_calls(expected_num_events=1) as events,):result = self.api_post(sender, "/api/v1/typing", params)@@ -514,7 +514,7 @@ class TypingHappyPathTestStreams(ZulipTestCase):)with (- self.assert_database_query_count(6),+ self.assert_database_query_count(8),self.capture_send_event_calls(expected_num_events=1) as events,):result = self.api_post(sender, "/api/v1/typing", params)@@ -549,7 +549,7 @@ class TypingHappyPathTestStreams(ZulipTestCase):)with self.settings(MAX_STREAM_SIZE_FOR_TYPING_NOTIFICATIONS=5):with (- self.assert_database_query_count(5),+ self.assert_database_query_count(7),self.capture_send_event_calls(expected_num_events=0) as events,):result = self.api_post(sender, "/api/v1/typing", params)@@ -606,7 +606,7 @@ class TypingHappyPathTestStreams(ZulipTestCase):)with (- self.assert_database_query_count(6),+ self.assert_database_query_count(8),self.capture_send_event_calls(expected_num_events=1) as events,):result = self.api_post(sender, "/api/v1/typing", params)diff --git a/zerver/views/typing.py b/zerver/views/typing.pyindex c8efdf0b194..5d6a981f8b9 100644--- a/zerver/views/typing.py+++ b/zerver/views/typing.py@@ -14,7 +14,7 @@ from zerver.actions.typing import (from zerver.lib.exceptions import JsonableErrorfrom zerver.lib.message import access_messagefrom zerver.lib.response import json_success-from zerver.lib.streams import access_stream_by_id_for_message, access_stream_for_send_message+from zerver.lib.streams import access_stream_by_id, access_stream_for_send_messagefrom zerver.lib.topic import (maybe_rename_general_chat_to_empty_topic,maybe_rename_no_topic_to_empty_topic,@@ -54,7 +54,7 @@ def send_notification_backend(# Verify that the user has access to the stream and has# permission to send messages to it.- stream = access_stream_by_id_for_message(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)topic = maybe_rename_general_chat_to_empty_topic(topic)topic = maybe_rename_no_topic_to_empty_topic(topic)