org_settings: Add backend for realm_jitsi_server_url setting.

This commit adds a `jitsi_server_url` field to the Realm model, which
will be used to save the URL of the custom Jitsi Meet server. In
the database, `None` will encode the server-level default. We can't
readily use `None` in the API, as it could be confused with "field not
sent". Therefore, we will use the string "default" for this purpose.

We have also introduced `server_jitsi_server_url` in the `/register`
API. This will be used to display the server's default Jitsi server
URL in the settings UI.

The existing `jitsi_server_url` will now be calculated as
`realm_jitsi_server_url || server_jitsi_server_url`.

Fixes a part of #17914.

Co-authored-by: Gaurav Pandey <gauravguitarrocks@gmail.com>
This commit is contained in:
Hemant Umre
2023-09-19 22:33:08 +05:30
committed by Tim Abbott
parent cb0aaa5197
commit be653dd5b4
11 changed files with 181 additions and 8 deletions

View File

@@ -337,10 +337,15 @@ def fetch_initial_state_data(
state["realm_push_notifications_enabled"] = push_notifications_enabled()
state["realm_default_external_accounts"] = get_default_external_accounts()
if settings.JITSI_SERVER_URL is not None:
state["jitsi_server_url"] = settings.JITSI_SERVER_URL.rstrip("/")
else: # nocoverage
state["jitsi_server_url"] = None
server_default_jitsi_server_url = (
settings.JITSI_SERVER_URL.rstrip("/") if settings.JITSI_SERVER_URL is not None else None
)
state["server_jitsi_server_url"] = server_default_jitsi_server_url
state["jitsi_server_url"] = (
realm.jitsi_server_url
if realm.jitsi_server_url is not None
else server_default_jitsi_server_url
)
if realm.notifications_stream and not realm.notifications_stream.deactivated:
notifications_stream = realm.notifications_stream
@@ -1068,6 +1073,13 @@ def apply_event(
state["zulip_plan_is_not_limited"] = event["value"] != Realm.PLAN_TYPE_LIMITED
state["realm_upload_quota_mib"] = event["extra_data"]["upload_quota"]
if field == "realm_jitsi_server_url":
state["jitsi_server_url"] = (
state["realm_jitsi_server_url"]
if state["realm_jitsi_server_url"] is not None
else state["server_jitsi_server_url"]
)
policy_permission_dict = {
"create_public_stream_policy": "can_create_public_streams",
"create_private_stream_policy": "can_create_private_streams",