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.

realm: Add an alias `realm_url` and deprecate `realm_uri` in the API.

Vector73ac4dde24ae85
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index 754f1e01e13..e8a46ffd319 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,16 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 9.0
+**Feature level 257**:
+
+* [`POST /register`](/api/register-queue),
+ [`POST /server_settings`](/api/get-server-settings), `PATCH /realm`:
+ `realm_uri` was renamed to `realm_url`, but remains available as a
+ deprecated alias for backwards-compatibility.
+* Mobile push notification payloads, similarly, have a new `realm_url`,
+ replacing `realm_uri`, which remains available as a deprecated alias
+ for backwards-compatibility.
+
**Feature level 256**
* [`GET /events`](/api/get-events): Stream update events with a new
diff --git a/version.py b/version.py
index f2ec5597ee3..5ce318009fd 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 = 256
+API_FEATURE_LEVEL = 257
# 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/context_processors.py b/zerver/context_processors.py
index 62c31e829c6..9fb2250e4ce 100644
--- a/zerver/context_processors.py
+++ b/zerver/context_processors.py
@@ -191,6 +191,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
"external_host": settings.EXTERNAL_HOST,
"external_url_scheme": settings.EXTERNAL_URI_SCHEME,
"realm_uri": realm_uri,
+ "realm_url": realm_uri,
"realm_name": realm_name,
"realm_icon": realm_icon,
"root_domain_url": settings.ROOT_DOMAIN_URI,
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 283ecee64aa..b47c4e73bb9 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -309,7 +309,9 @@ def fetch_initial_state_data(
state["realm_icon_source"] = realm.icon_source
add_realm_logo_fields(state, realm)
- state["realm_uri"] = realm.url
+ # TODO/compatibility: realm_uri is a deprecated alias for realm_url that
+ # can be removed once there are no longer clients relying on it.
+ state["realm_url"] = state["realm_uri"] = realm.url
state["realm_bot_domain"] = realm.get_bot_domain()
state["realm_available_video_chat_providers"] = realm.VIDEO_CHAT_PROVIDERS
state["settings_send_digest_emails"] = settings.SEND_DIGEST_EMAILS
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py
index f359b225353..f5e4f0cdcd6 100644
--- a/zerver/lib/push_notifications.py
+++ b/zerver/lib/push_notifications.py
@@ -949,6 +949,7 @@ def get_base_payload(user_profile: UserProfile) -> Dict[str, Any]:
data["server"] = settings.EXTERNAL_HOST
data["realm_id"] = user_profile.realm.id
data["realm_uri"] = user_profile.realm.url
+ data["realm_url"] = user_profile.realm.url
data["realm_name"] = user_profile.realm.name
data["user_id"] = user_profile.id
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 7c5e37efdab..95b26ee1411 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -15256,11 +15256,24 @@ paths:
The fake email domain that will be used for new bots created this
organization. Useful for UI for creating bots.
realm_uri:
+ type: string
+ deprecated: true
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ The URL for the organization. Alias of `realm_url`.
+
+ **Changes**: Deprecated in Zulip 9.0 (feature level 257). The term
+ "URI" is deprecated in [web standards](https://url.spec.whatwg.org/#goals).
+ realm_url:
type: string
description: |
Present if `realm` is present in `fetch_event_types`.
The URL for the organization.
+
+ **Changes**: New in Zulip 9.0 (feature level 257), replacing the
+ deprecated `realm_uri`.
realm_available_video_chat_providers:
type: object
description: |
@@ -16656,9 +16669,20 @@ paths:
[ldap-auth]: https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#ldap-including-active-directory
realm_uri:
+ type: string
+ deprecated: true
+ description: |
+ The organization's canonical URL. Alias of `realm_url`.
+
+ **Changes**: Deprecated in Zulip 9.0 (feature level 257). The term
+ "URI" is deprecated in [web standards](https://url.spec.whatwg.org/#goals).
+ realm_url:
type: string
description: |
The organization's canonical URL.
+
+ **Changes**: New in Zulip 9.0 (feature level 257), replacing the
+ deprecated `realm_uri`.
realm_name:
type: string
description: |
@@ -16708,6 +16732,7 @@ paths:
"email_auth_enabled": true,
"require_email_format_usernames": true,
"realm_uri": "http://localhost:9991",
+ "realm_url": "http://localhost:9991",
"realm_name": "Zulip Dev",
"realm_icon": "https://secure.gravatar.com/avatar/62429d594b6ffc712f54aee976a18b44?d=identicon",
"realm_description": "<p>The Zulip development environment default organization. It's great for testing!</p>",
diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py
index a0414ababbb..0c9f0a4d0d8 100644
--- a/zerver/tests/test_auth_backends.py
+++ b/zerver/tests/test_auth_backends.py
@@ -5218,6 +5218,7 @@ class FetchAuthBackends(ZulipTestCase):
("email_auth_enabled", check_bool),
("is_incompatible", check_bool),
("require_email_format_usernames", check_bool),
+ ("realm_url", check_string),
("realm_uri", check_string),
("zulip_version", check_string),
("zulip_merge_base", check_string),
@@ -5241,6 +5242,7 @@ class FetchAuthBackends(ZulipTestCase):
result = self.client_get(
"/api/v1/server_settings", subdomain="", HTTP_USER_AGENT="ZulipInvalid"
)
+
response_dict = self.assert_json_success(result)
self.assertTrue(response_dict["is_incompatible"])
diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.py
index 5c053cbea56..0e93f741086 100644
--- a/zerver/tests/test_event_system.py
+++ b/zerver/tests/test_event_system.py
@@ -171,6 +171,7 @@ class EventsEndpointTest(ZulipTestCase):
result = self.client_post("/json/register")
result_dict = self.assert_json_success(result)
self.assertEqual(result_dict["queue_id"], None)
+ self.assertEqual(result_dict["realm_url"], "http://zulip.testserver")
self.assertEqual(result_dict["realm_uri"], "http://zulip.testserver")
result = self.client_post("/json/register")
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index 34237b1599d..f0b40d4b1d3 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -192,6 +192,7 @@ class HomeTest(ZulipTestCase):
"realm_signup_announcements_stream_id",
"realm_upload_quota_mib",
"realm_uri",
+ "realm_url",
"realm_user_group_edit_policy",
"realm_user_groups",
"realm_user_settings_defaults",
diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py
index ef6a3b10625..28ed65cb9bf 100644
--- a/zerver/tests/test_push_notifications.py
+++ b/zerver/tests/test_push_notifications.py
@@ -211,6 +211,7 @@ class SendTestPushNotificationEndpointTest(BouncerTestCase):
"realm_id": user.realm_id,
"realm_name": "Zulip Dev",
"realm_uri": "http://zulip.testserver",
+ "realm_url": "http://zulip.testserver",
"user_id": user.id,
"event": "test",
"time": datetime_to_timestamp(time_now),
@@ -242,6 +243,7 @@ class SendTestPushNotificationEndpointTest(BouncerTestCase):
"realm_id": user.realm_id,
"realm_name": "Zulip Dev",
"realm_uri": "http://zulip.testserver",
+ "realm_url": "http://zulip.testserver",
"user_id": user.id,
"event": "test",
}
@@ -317,6 +319,7 @@ class SendTestPushNotificationEndpointTest(BouncerTestCase):
"realm_id": user.realm_id,
"realm_name": "Zulip Dev",
"realm_uri": "http://zulip.testserver",
+ "realm_url": "http://zulip.testserver",
"user_id": user.id,
"event": "test",
"time": datetime_to_timestamp(time_now),
@@ -775,6 +778,7 @@ class PushBouncerNotificationTest(BouncerTestCase):
"server": settings.EXTERNAL_HOST,
"realm_id": hamlet.realm.id,
"realm_uri": hamlet.realm.url,
+ "realm_url": hamlet.realm.url,
"user_id": self.example_user("othello").id,
}
},
@@ -790,6 +794,7 @@ class PushBouncerNotificationTest(BouncerTestCase):
"server": settings.EXTERNAL_HOST,
"realm_id": hamlet.realm.id,
"realm_uri": hamlet.realm.url,
+ "realm_url": hamlet.realm.url,
"sender_id": hamlet.id,
"sender_email": hamlet.email,
"sender_full_name": "King Hamlet",
@@ -3351,6 +3356,7 @@ class HandlePushNotificationTest(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": "http://zulip.testserver",
+ "realm_url": "http://zulip.testserver",
"user_id": self.user_profile.id,
"event": "remove",
"zulip_message_ids": str(message.id),
@@ -3362,6 +3368,7 @@ class HandlePushNotificationTest(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": "http://zulip.testserver",
+ "realm_url": "http://zulip.testserver",
"user_id": self.user_profile.id,
"event": "remove",
"zulip_message_ids": str(message.id),
@@ -3426,6 +3433,7 @@ class HandlePushNotificationTest(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": "http://zulip.testserver",
+ "realm_url": "http://zulip.testserver",
"user_id": self.user_profile.id,
"event": "remove",
"zulip_message_ids": str(message.id),
@@ -3444,6 +3452,7 @@ class HandlePushNotificationTest(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": "http://zulip.testserver",
+ "realm_url": "http://zulip.testserver",
"user_id": self.user_profile.id,
"event": "remove",
"zulip_message_ids": str(message.id),
@@ -3953,6 +3962,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
+ "realm_url": self.sender.realm.url,
"user_id": user_profile.id,
"time": datetime_to_timestamp(message.date_sent),
},
@@ -3997,6 +4007,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
+ "realm_url": self.sender.realm.url,
"user_id": user_profile.id,
"time": datetime_to_timestamp(message.date_sent),
},
@@ -4030,6 +4041,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
+ "realm_url": self.sender.realm.url,
"user_id": self.sender.id,
"time": datetime_to_timestamp(message.date_sent),
},
@@ -4069,6 +4081,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
+ "realm_url": self.sender.realm.url,
"user_id": user_profile.id,
"time": datetime_to_timestamp(message.date_sent),
},
@@ -4107,6 +4120,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
+ "realm_url": self.sender.realm.url,
"user_id": user_profile.id,
"mentioned_user_group_id": user_group.id,
"mentioned_user_group_name": user_group.name,
@@ -4146,6 +4160,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
+ "realm_url": self.sender.realm.url,
"user_id": user_profile.id,
"time": datetime_to_timestamp(message.date_sent),
},
@@ -4208,6 +4223,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
+ "realm_url": self.sender.realm.url,
"user_id": user_profile.id,
"time": datetime_to_timestamp(message.date_sent),
},
@@ -4258,6 +4274,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"realm_id": hamlet.realm.id,
"realm_name": hamlet.realm.name,
"realm_uri": hamlet.realm.url,
+ "realm_url": hamlet.realm.url,
"user_id": polonius.id,
"time": datetime_to_timestamp(message.date_sent),
}
@@ -4297,6 +4314,7 @@ class TestGetGCMPayload(PushNotificationTest):
"realm_id": hamlet.realm.id,
"realm_name": hamlet.realm.name,
"realm_uri": hamlet.realm.url,
+ "realm_url": hamlet.realm.url,
"sender_id": hamlet.id,
"sender_email": hamlet.email,
"sender_full_name": "King Hamlet",
@@ -4356,6 +4374,7 @@ class TestGetGCMPayload(PushNotificationTest):
"realm_id": hamlet.realm.id,
"realm_name": hamlet.realm.name,
"realm_uri": hamlet.realm.url,
+ "realm_url": hamlet.realm.url,
"sender_id": hamlet.id,
"sender_email": hamlet.email,
"sender_full_name": "King Hamlet",
@@ -4389,6 +4408,7 @@ class TestGetGCMPayload(PushNotificationTest):
"realm_id": hamlet.realm.id,
"realm_name": hamlet.realm.name,
"realm_uri": hamlet.realm.url,
+ "realm_url": hamlet.realm.url,
"sender_id": hamlet.id,
"sender_email": hamlet.email,
"sender_full_name": "King Hamlet",
@@ -4439,6 +4459,7 @@ class TestGetGCMPayload(PushNotificationTest):
"realm_id": hamlet.realm.id,
"realm_name": hamlet.realm.name,
"realm_uri": hamlet.realm.url,
+ "realm_url": hamlet.realm.url,
"sender_id": hamlet.id,
"sender_email": f"user{hamlet.id}@zulip.testserver",
"sender_full_name": "Unknown user",
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index 0b63ccd4bcf..5d80a526d81 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -243,6 +243,7 @@ class RealmTest(ZulipTestCase):
self.assert_json_success(result)
json = orjson.loads(result.content)
self.assertEqual(json["realm_uri"], "http://coolrealm.testserver")
+ self.assertEqual(json["realm_url"], "http://coolrealm.testserver")
realm = get_realm("coolrealm")
self.assertIsNone(realm.demo_organization_scheduled_deletion_date)
self.assertEqual(realm.string_id, data["string_id"])
diff --git a/zerver/views/auth.py b/zerver/views/auth.py
index b448f16a5e7..e9cffe568ce 100644
--- a/zerver/views/auth.py
+++ b/zerver/views/auth.py
@@ -1120,7 +1120,7 @@ def api_get_server_settings(request: HttpRequest) -> HttpResponse:
for settings_item in [
"email_auth_enabled",
"require_email_format_usernames",
- "realm_uri",
+ "realm_url",
"realm_name",
"realm_icon",
"realm_description",
@@ -1129,6 +1129,8 @@ def api_get_server_settings(request: HttpRequest) -> HttpResponse:
]:
if context[settings_item] is not None:
result[settings_item] = context[settings_item]
+ # TODO/compatibility: Backwards-compatibility name for realm_url.
+ result["realm_uri"] = result["realm_url"]
return json_success(request, data=result)
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index ee6438e6199..6037c11f173 100644
--- a/zerver/views/realm.py
+++ b/zerver/views/realm.py
@@ -464,6 +464,7 @@ def update_realm(
do_change_realm_subdomain(realm, string_id, acting_user=user_profile)
data["realm_uri"] = realm.url
+ data["realm_url"] = realm.url
if org_type is not None:
do_change_realm_org_type(realm, org_type, acting_user=user_profile)