mirror of https://github.com/zulip/zulip.git
events: Send invites changes event to non-admin users also.
Earlier whenever a new invitation is created a event was sent to only admin users. So, if invites by a non-admins user are changed the invite panel does not live update. This commit makes changes to also send event to non-admin user if invites by them are changed.
This commit is contained in:
parent
5e31a6b1c0
commit
88ec312b21
|
@ -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 could
|
||||
create 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),
|
||||
|
|
|
@ -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. Bump
|
||||
|
|
|
@ -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 them
|
||||
|
|
|
@ -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_as
|
||||
invite.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_REVOKED
|
||||
multiuse_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:
|
||||
|
|
|
@ -955,10 +955,14 @@ paths:
|
|||
}
|
||||
- type: object
|
||||
description: |
|
||||
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 refetch
|
||||
data from `GET /invites` if they are displaying UI containing active
|
||||
invitations.
|
||||
|
||||
**Changes**: Before Zulip 8.0 (feature level 209), this event was
|
||||
only sent to organization administrators.
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/EventIdSchema"
|
||||
|
|
Loading…
Reference in New Issue