mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	create-channel: Remove send_new_subscription_messages parameter.
Removes send_new_subscription_messages parameter from `POST channel/create` endpoint as Notification Bot DMs are never sent when users are subscribed as part of creating a new channel. Not considered a documentable API change, since the previous parameter never had any effect, so this is effectively just a documentation and error-handling bug fix, not an API change relevant to implementors.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							dda2c6e285
						
					
				
				
					commit
					699c0c6200
				
			@@ -23730,8 +23730,6 @@ paths:
 | 
				
			|||||||
                  example: true
 | 
					                  example: true
 | 
				
			||||||
                folder_id:
 | 
					                folder_id:
 | 
				
			||||||
                  $ref: "#/components/schemas/FolderId"
 | 
					                  $ref: "#/components/schemas/FolderId"
 | 
				
			||||||
                send_new_subscription_messages:
 | 
					 | 
				
			||||||
                  $ref: "#/components/schemas/SendNewSubscriptionMessages"
 | 
					 | 
				
			||||||
                topics_policy:
 | 
					                topics_policy:
 | 
				
			||||||
                  $ref: "#/components/schemas/TopicsPolicy"
 | 
					                  $ref: "#/components/schemas/TopicsPolicy"
 | 
				
			||||||
                history_public_to_subscribers:
 | 
					                history_public_to_subscribers:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ from zerver.models import (
 | 
				
			|||||||
    Message,
 | 
					    Message,
 | 
				
			||||||
    NamedUserGroup,
 | 
					    NamedUserGroup,
 | 
				
			||||||
    Realm,
 | 
					    Realm,
 | 
				
			||||||
 | 
					    Recipient,
 | 
				
			||||||
    Stream,
 | 
					    Stream,
 | 
				
			||||||
    Subscription,
 | 
					    Subscription,
 | 
				
			||||||
    UserMessage,
 | 
					    UserMessage,
 | 
				
			||||||
@@ -303,6 +304,18 @@ class TestCreateStreams(ZulipTestCase):
 | 
				
			|||||||
        self.assertEqual(stream.name, "testchannel")
 | 
					        self.assertEqual(stream.name, "testchannel")
 | 
				
			||||||
        self.assertEqual(stream.description, "test channel")
 | 
					        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.
 | 
					        # Creating an existing channel should return an error.
 | 
				
			||||||
        result = self.create_channel_via_post(user_profile, name="basketball")
 | 
					        result = self.create_channel_via_post(user_profile, name="basketball")
 | 
				
			||||||
        self.assert_json_error(result, "Channel 'basketball' already exists", status_code=409)
 | 
					        self.assert_json_error(result, "Channel 'basketball' already exists", status_code=409)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -738,7 +738,6 @@ def create_channel(
 | 
				
			|||||||
    is_default_stream: Json[bool] = False,
 | 
					    is_default_stream: Json[bool] = False,
 | 
				
			||||||
    message_retention_days: Json[str] | Json[int] = RETENTION_DEFAULT,
 | 
					    message_retention_days: Json[str] | Json[int] = RETENTION_DEFAULT,
 | 
				
			||||||
    name: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)],
 | 
					    name: Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)],
 | 
				
			||||||
    send_new_subscription_messages: Json[bool] = True,
 | 
					 | 
				
			||||||
    subscribers: Json[list[int]],
 | 
					    subscribers: Json[list[int]],
 | 
				
			||||||
    topics_policy: Json[TopicsPolicy] = None,
 | 
					    topics_policy: Json[TopicsPolicy] = None,
 | 
				
			||||||
) -> HttpResponse:
 | 
					) -> HttpResponse:
 | 
				
			||||||
@@ -825,15 +824,13 @@ def create_channel(
 | 
				
			|||||||
        new_subscribers,
 | 
					        new_subscribers,
 | 
				
			||||||
        acting_user=user_profile,
 | 
					        acting_user=user_profile,
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    if (
 | 
					    # We never send DM notifications about newly created channels, so we only
 | 
				
			||||||
        send_new_subscription_messages
 | 
					    # need to send the data for the new channel notification messages.
 | 
				
			||||||
        and len(new_subscribers) <= settings.MAX_BULK_NEW_SUBSCRIPTION_MESSAGES
 | 
					 | 
				
			||||||
    ):
 | 
					 | 
				
			||||||
    send_user_subscribed_and_new_channel_notifications(
 | 
					    send_user_subscribed_and_new_channel_notifications(
 | 
				
			||||||
        user_profile=user_profile,
 | 
					        user_profile=user_profile,
 | 
				
			||||||
            subscribers=new_subscribers,
 | 
					        subscribers=set(),
 | 
				
			||||||
            new_subscriptions={str(user.id): [name] for user in new_subscribers},
 | 
					        new_subscriptions={},
 | 
				
			||||||
            id_to_user_profile={str(user.id): user for user in new_subscribers},
 | 
					        id_to_user_profile={},
 | 
				
			||||||
        created_streams=[new_channel],
 | 
					        created_streams=[new_channel],
 | 
				
			||||||
        announce=announce,
 | 
					        announce=announce,
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user