Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

invites: Allow users to invite without specifying any stream to join.

Sahil Batra4ca887bade96
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index a0bc8114465..0383f6a867b 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 7.0
+**Feature level 180**
+
+* `POST /invites`: Added support for invitations specifying the empty
+ list as the user's initial stream subscriptions. Previously, this
+ returned an error.
+
**Feature level 179**:
* [`POST /scheduled_messages`](/api/create-or-update-scheduled-message):
diff --git a/version.py b/version.py
index e3d2ab20c2a..0c65315773f 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
# Changes should be accompanied by documentation explaining what the
# new level means in api_docs/changelog.md, as well as "**Changes**"
# entries in the endpoint's documentation in `zulip.yaml`.
-API_FEATURE_LEVEL = 179
+API_FEATURE_LEVEL = 180
# Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump
diff --git a/web/src/invite.js b/web/src/invite.js
index daacc938a74..68a4412c23d 100644
--- a/web/src/invite.js
+++ b/web/src/invite.js
@@ -260,9 +260,8 @@ function open_invite_user_modal(e) {
function toggle_invite_submit_button() {
$("#invite-user-modal .dialog_submit_button").prop(
"disabled",
- ($("#invitee_emails").val().trim() === "" &&
- !$("#generate_multiuse_invite_radio").is(":checked")) ||
- $("#streams_to_add input:checked").length === 0,
+ $("#invitee_emails").val().trim() === "" &&
+ !$("#generate_multiuse_invite_radio").is(":checked"),
);
}
@@ -326,10 +325,6 @@ function open_invite_user_modal(e) {
$("#invite_uncheck_all_button").on("click", () => {
$("#streams_to_add input[type=checkbox]").prop("checked", false);
- $("#invite-user-modal .dialog_submit_button").prop(
- "disabled",
- !$("#generate_multiuse_invite_radio").is(":checked"),
- );
});
}
diff --git a/zerver/tests/test_invite.py b/zerver/tests/test_invite.py
index 91e73f96225..170141eb1e2 100644
--- a/zerver/tests/test_invite.py
+++ b/zerver/tests/test_invite.py
@@ -704,6 +704,18 @@ class InviteUserTest(InviteUserBase):
self.submit_reg_form_for_user(invitee, "password")
self.check_user_subscribed_only_to_streams("alice", streams)
+ invitee = self.nonreg_email("bob")
+ self.assert_json_success(self.invite(invitee, []))
+ self.assertTrue(find_key_by_email(invitee))
+
+ default_streams = get_default_streams_for_realm(realm.id)
+ self.assert_length(default_streams, 1)
+
+ self.submit_reg_form_for_user(invitee, "password")
+ # If no streams are provided, user is not subscribed to
+ # default streams as well.
+ self.check_user_subscribed_only_to_streams("bob", [])
+
def test_can_invite_others_to_realm(self) -> None:
def validation_func(user_profile: UserProfile) -> bool:
user_profile.refresh_from_db()
@@ -921,11 +933,6 @@ [email protected]""",
do_set_realm_property(realm, "emails_restricted_to_domains", True, acting_user=None)
self.login("hamlet")
- invitee_emails = "[email protected]"
- self.assert_json_error(
- self.invite(invitee_emails, []),
- "You must specify at least one stream for invitees to join.",
- )
for address in ("noatsign.com", "[email protected]"):
self.assert_json_error(
diff --git a/zerver/views/invite.py b/zerver/views/invite.py
index 78cd106567f..cb98e5557d5 100644
--- a/zerver/views/invite.py
+++ b/zerver/views/invite.py
@@ -70,8 +70,6 @@ def invite_users_backend(
raise JsonableError(_("Must be an organization administrator"))
if not invitee_emails_raw:
raise JsonableError(_("You must specify at least one email address."))
- if not stream_ids:
- raise JsonableError(_("You must specify at least one stream for invitees to join."))
invitee_emails = get_invitee_emails_set(invitee_emails_raw)