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.

bots: Send realm_bot update event when bot email changes.

Pritesh Shetty5a1169e9699e
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index fceb37248bb..ecf64a22425 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,11 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 12.0
+**Feature level 461**
+
+* [`GET /events`](/api/get-events): `realm_bot` update events are
+ now sent when a bot's Zulip display email address is changed.
+
**Feature level 460**
* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
diff --git a/version.py b/version.py
index 106cf391f9a..c3d8a0eeff8 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# https://zulip.readthedocs.io/en/latest/documentation/api.html#step-by-step-guide
# Also available at docs/documentation/api.md.
-API_FEATURE_LEVEL = 460
+API_FEATURE_LEVEL = 461
# 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/zerver/actions/user_settings.py b/zerver/actions/user_settings.py
index fd5060f419b..5871f79a1d1 100644
--- a/zerver/actions/user_settings.py
+++ b/zerver/actions/user_settings.py
@@ -134,6 +134,15 @@ def do_change_user_delivery_email(
send_event_on_commit(user_profile.realm, event, delivery_email_visible_user_ids)
+ if user_profile.is_bot:
+ bot_payload = dict(user_id=user_profile.id, email=new_email)
+ bot_event = dict(type="realm_bot", op="update", bot=bot_payload)
+ send_event_on_commit(
+ user_profile.realm,
+ bot_event,
+ bot_owner_user_ids(user_profile),
+ )
+
if user_profile.avatar_source == UserProfile.AVATAR_FROM_GRAVATAR:
# If the user is using Gravatar to manage their email address,
# their Gravatar just changed, and we need to notify other
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 88b061743e3..99da8e8caf4 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -25713,6 +25713,13 @@ components:
owner_id:
nullable: true
services: {}
+ email:
+ type: string
+ description: |
+ The Zulip display email address of the bot, used for authentication.
+
+ **Changes**: New in Zulip 12.0 (feature level 461). Previously,
+ only `realm_user` events were sent when updating a bot’s email.
is_active:
type: boolean
description: |