api: Expose server_needs_upgrade in register response.

Expose the boolean value server_needs_upgrade in the
responses for register api so that it can be used
by mobile and terminal clients as well.
Highlighted in api changelog as part of
feature level 74 in commit fb93c96
(next commit).
This commit is contained in:
Gaurav Pandey 2021-06-03 22:26:36 +05:30 committed by Tim Abbott
parent f82aba5a3d
commit 18ef0c3bc1
3 changed files with 13 additions and 2 deletions

View File

@ -22,6 +22,7 @@ from zerver.lib.actions import (
from zerver.lib.alert_words import user_alert_words from zerver.lib.alert_words import user_alert_words
from zerver.lib.avatar import avatar_url from zerver.lib.avatar import avatar_url
from zerver.lib.bot_config import load_bot_config_template from zerver.lib.bot_config import load_bot_config_template
from zerver.lib.compatibility import is_outdated_server
from zerver.lib.external_accounts import DEFAULT_EXTERNAL_ACCOUNTS from zerver.lib.external_accounts import DEFAULT_EXTERNAL_ACCOUNTS
from zerver.lib.hotspots import get_next_hotspots from zerver.lib.hotspots import get_next_hotspots
from zerver.lib.integrations import EMBEDDED_BOTS, WEBHOOK_INTEGRATIONS from zerver.lib.integrations import EMBEDDED_BOTS, WEBHOOK_INTEGRATIONS
@ -275,6 +276,8 @@ def fetch_initial_state_data(
state["server_name_changes_disabled"] = settings.NAME_CHANGES_DISABLED state["server_name_changes_disabled"] = settings.NAME_CHANGES_DISABLED
state["giphy_rating_options"] = realm.GIPHY_RATING_OPTIONS state["giphy_rating_options"] = realm.GIPHY_RATING_OPTIONS
state["server_needs_upgrade"] = is_outdated_server(user_profile)
# TODO: Should these have the realm prefix replaced with server_? # TODO: Should these have the realm prefix replaced with server_?
state["realm_push_notifications_enabled"] = push_notifications_enabled() state["realm_push_notifications_enabled"] = push_notifications_enabled()
state["realm_default_external_accounts"] = DEFAULT_EXTERNAL_ACCOUNTS state["realm_default_external_accounts"] = DEFAULT_EXTERNAL_ACCOUNTS

View File

@ -8,7 +8,6 @@ from django.http import HttpRequest
from django.utils import translation from django.utils import translation
from two_factor.utils import default_device from two_factor.utils import default_device
from zerver.lib.compatibility import is_outdated_server
from zerver.lib.events import do_events_register from zerver.lib.events import do_events_register
from zerver.lib.i18n import ( from zerver.lib.i18n import (
get_and_set_request_language, get_and_set_request_language,
@ -186,7 +185,6 @@ def build_page_params_for_home_page_load(
test_suite=settings.TEST_SUITE, test_suite=settings.TEST_SUITE,
poll_timeout=settings.POLL_TIMEOUT, poll_timeout=settings.POLL_TIMEOUT,
insecure_desktop_app=insecure_desktop_app, insecure_desktop_app=insecure_desktop_app,
server_needs_upgrade=is_outdated_server(user_profile),
login_page=settings.HOME_NOT_LOGGED_IN, login_page=settings.HOME_NOT_LOGGED_IN,
save_stacktraces=settings.SAVE_FRONTEND_STACKTRACES, save_stacktraces=settings.SAVE_FRONTEND_STACKTRACES,
warn_no_email=settings.WARN_NO_EMAIL, warn_no_email=settings.WARN_NO_EMAIL,

View File

@ -8976,6 +8976,16 @@ paths:
Whether the server allows name changes. Similar to Whether the server allows name changes. Similar to
`realm_name_changes_disabled` but based on the `NAME_CHANGES_DISABLED` `realm_name_changes_disabled` but based on the `NAME_CHANGES_DISABLED`
Zulip server level setting. Zulip server level setting.
server_needs_upgrade:
type: boolean
description: |
Present if `realm` is present in `fetch_event_types`.
Whether the server is running an old version based on the Zulip
[server release lifecycle](https://zulip.readthedocs.io/en/latest/overview/release-lifecycle.html#upgrade-nag),
such that the web app will display to the current user a prominent warning.
**Changes**: New in Zulip 5.0 (feature level 74).
realm_notifications_stream_id: realm_notifications_stream_id:
type: integer type: integer
description: | description: |