api: Add a monotonic integer "feature level" for non-webapp clients.

The purpose is to provide a way for (non-webapp) clients,
like the mobile and terminal apps, to tell whether the
server it's talking to is new enough to support a given
API feature -- in particular a way that

* is finer-grained than release numbers, so that for
features developed after e.g. 2.1.0 we can use them
immediately on servers deployed from master (like
chat.zulip.org and zulipchat.com) without waiting the
months until a 2.2 release;

* is reliable, unlike e.g. looking at the number of
commits since a release;

* doesn't lead to a growing bag of named feature flags
which the server has to go on sending forever.

Tweaked by tabbott to extend the documentation.

Closes #14618.
This commit is contained in:
Hashir Sarwar
2020-04-20 03:57:28 +05:00
committed by Tim Abbott
parent 0de77cabb0
commit e3b90a5ec8
7 changed files with 36 additions and 3 deletions

View File

@@ -45,7 +45,7 @@ from zproject.backends import password_auth_enabled, dev_auth_enabled, \
ldap_auth_enabled, ZulipLDAPConfigurationError, ZulipLDAPAuthBackend, \
AUTH_BACKEND_NAME_MAP, auth_enabled_helper, saml_auth_enabled, SAMLAuthBackend, \
redirect_to_config_error, ZulipRemoteUserBackend, validate_otp_params
from version import ZULIP_VERSION
from version import ZULIP_VERSION, API_FEATURE_LEVEL
import jwt
import logging
@@ -946,6 +946,7 @@ def api_get_server_settings(request: HttpRequest) -> HttpResponse:
result = dict(
authentication_methods=get_auth_backends_data(request),
zulip_version=ZULIP_VERSION,
zulip_feature_level=API_FEATURE_LEVEL,
push_notifications_enabled=push_notifications_enabled(),
is_incompatible=check_server_incompatibility(request),
)