diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 654cb70ea0..f0e8833de2 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -23857,8 +23857,6 @@ paths: example: true folder_id: $ref: "#/components/schemas/FolderId" - send_new_subscription_messages: - $ref: "#/components/schemas/SendNewSubscriptionMessages" topics_policy: $ref: "#/components/schemas/TopicsPolicy" history_public_to_subscribers: diff --git a/zerver/tests/test_channel_creation.py b/zerver/tests/test_channel_creation.py index 31ff60f528..0563f87bf6 100644 --- a/zerver/tests/test_channel_creation.py +++ b/zerver/tests/test_channel_creation.py @@ -24,6 +24,7 @@ from zerver.models import ( Message, NamedUserGroup, Realm, + Recipient, Stream, Subscription, UserMessage, @@ -303,6 +304,18 @@ class TestCreateStreams(ZulipTestCase): self.assertEqual(stream.name, "testchannel") self.assertEqual(stream.description, "test channel") + # Confirm channel created notification message in channel events topic. + message = self.get_last_message() + self.assertEqual(message.recipient.type, Recipient.STREAM) + self.assertEqual(message.recipient.type_id, stream.id) + self.assertEqual(message.topic_name(), Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME) + self.assertEqual(message.sender_id, self.notification_bot(user_profile.realm).id) + expected_message_content = ( + f"**Public** channel created by @_**{user_profile.full_name}|{user_profile.id}**. **Description:**\n" + "```` quote\ntest channel\n````" + ) + self.assertEqual(message.content, expected_message_content) + # Creating an existing channel should return an error. result = self.create_channel_via_post(user_profile, name="basketball") self.assert_json_error(result, "Channel 'basketball' already exists", status_code=409) diff --git a/zerver/views/streams.py b/zerver/views/streams.py index 940ae79cb9..7f36833a6a 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -738,7 +738,6 @@ def create_channel( is_default_stream: Json[bool] = False, message_retention_days: Json[str] | Json[int] = RETENTION_DEFAULT, name: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)], - send_new_subscription_messages: Json[bool] = True, subscribers: Json[list[int]], topics_policy: Json[TopicsPolicy] = None, ) -> HttpResponse: @@ -825,18 +824,16 @@ def create_channel( new_subscribers, acting_user=user_profile, ) - if ( - send_new_subscription_messages - and len(new_subscribers) <= settings.MAX_BULK_NEW_SUBSCRIPTION_MESSAGES - ): - send_user_subscribed_and_new_channel_notifications( - user_profile=user_profile, - subscribers=new_subscribers, - new_subscriptions={str(user.id): [name] for user in new_subscribers}, - id_to_user_profile={str(user.id): user for user in new_subscribers}, - created_streams=[new_channel], - announce=announce, - ) + # We never send DM notifications about newly created channels, so we only + # need to send the data for the new channel notification messages. + send_user_subscribed_and_new_channel_notifications( + user_profile=user_profile, + subscribers=set(), + new_subscriptions={}, + id_to_user_profile={}, + created_streams=[new_channel], + announce=announce, + ) return json_success( request,