Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
events: Send invites changes event to non-admin users also.
Ujjawal Modi88ec312b2167
diff --git a/api_docs/changelog.md b/api_docs/changelog.mdindex 019911374a2..83ede5b2c7a 100644--- a/api_docs/changelog.md+++ b/api_docs/changelog.md@@ -42,6 +42,11 @@ format used by the Zulip server that they are interacting with.reusable invitation links they have created. Previously, only admin users couldcreate and revoke reusable invitation links.+* [`GET /events`](/api/get-events): When the set of invitations in an+ organization changes, an `invites_changed` event is now sent to the+ creator of the changed invitation, as well as all admin users.+ Previously, this event was only sent to admin users.+**Feature level 208*** [`POST /users/me/subscriptions`](/api/subscribe),diff --git a/version.py b/version.pyindex f57744c92be..734b4932ae5 100644--- a/version.py+++ b/version.py@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.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 = 208+API_FEATURE_LEVEL = 209# 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. Bumpdiff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.pyindex 9f7b2201238..4da6872adc2 100644--- a/zerver/actions/create_user.py+++ b/zerver/actions/create_user.py@@ -273,7 +273,7 @@ def process_new_human_user().update(status=confirmation_settings.STATUS_REVOKED)if prereg_user is not None and prereg_user.referred_by is not None:- notify_invites_changed(user_profile.realm)+ notify_invites_changed(user_profile.realm, changed_invite_referrer=prereg_user.referred_by)notify_new_user(user_profile)# Clear any scheduled invitation emails to prevent themdiff --git a/zerver/actions/invites.py b/zerver/actions/invites.pyindex fbaf23a89ce..607832703e4 100644--- a/zerver/actions/invites.py+++ b/zerver/actions/invites.py@@ -36,10 +36,15 @@ from zerver.models import (from zerver.tornado.django_api import send_event-def notify_invites_changed(realm: Realm) -> None:+def notify_invites_changed(+ realm: Realm, *, changed_invite_referrer: Optional[UserProfile] = None+) -> None:event = dict(type="invites_changed")admin_ids = [user.id for user in realm.get_admin_users_and_bots()]- send_event(realm, event, admin_ids)+ recipient_ids = admin_ids+ if changed_invite_referrer and changed_invite_referrer.id not in recipient_ids:+ recipient_ids.append(changed_invite_referrer.id)+ send_event(realm, event, recipient_ids)def do_send_confirmation_email(@@ -321,7 +326,7 @@ def do_invite_users(skipped,sent_invitations=True,)- notify_invites_changed(user_profile.realm)+ notify_invites_changed(user_profile.realm, changed_invite_referrer=user_profile)def get_invitation_expiry_date(confirmation_obj: Confirmation) -> Optional[int]:@@ -446,7 +451,7 @@ def do_create_multiuse_invite_link(invite.streams.set(streams)invite.invited_as = invited_asinvite.save()- notify_invites_changed(referred_by.realm)+ notify_invites_changed(referred_by.realm, changed_invite_referrer=referred_by)return create_confirmation_link(invite, Confirmation.MULTIUSE_INVITE, validity_in_minutes=invite_expires_in_minutes)@@ -466,7 +471,7 @@ def do_revoke_user_invite(prereg_user: PreregistrationUser) -> None:Confirmation.objects.filter(content_type=content_type, object_id=prereg_user.id).delete()prereg_user.delete()clear_scheduled_invitation_emails(email)- notify_invites_changed(realm)+ notify_invites_changed(realm, changed_invite_referrer=prereg_user.referred_by)def do_revoke_multi_use_invite(multiuse_invite: MultiuseInvite) -> None:@@ -479,7 +484,7 @@ def do_revoke_multi_use_invite(multiuse_invite: MultiuseInvite) -> None:).delete()multiuse_invite.status = confirmation_settings.STATUS_REVOKEDmultiuse_invite.save(update_fields=["status"])- notify_invites_changed(realm)+ notify_invites_changed(realm, changed_invite_referrer=multiuse_invite.referred_by)def do_resend_user_invite_email(prereg_user: PreregistrationUser) -> int:diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 6fd106cd5a7..030f2cff02f 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -955,10 +955,14 @@ paths:}- type: objectdescription: |- A simple event sent to organization administrators when the- set of invitations changes; this tells clients they need to refetch+ A simple event sent when the set of invitations changes.+ This event is sent to organization administrators and the creator of+ the changed invitation; this tells clients they need to refetchdata from `GET /invites` if they are displaying UI containing activeinvitations.++ **Changes**: Before Zulip 8.0 (feature level 209), this event was+ only sent to organization administrators.properties:id:$ref: "#/components/schemas/EventIdSchema"