register:api: Provide additional fields that can be useful to clients.

Fixes #14166

* Bumped the api version to feature level 4.
See https://github.com/zulip/zulip/issues/14166#issuecomment-598961462
for details about implementation and future steps.
This commit is contained in:
Aman Agrawal 2020-05-08 13:32:10 +05:30 committed by Tim Abbott
parent 0c2b25cab3
commit 898e717b9d
4 changed files with 22 additions and 12 deletions

View File

@ -10,6 +10,16 @@ below features are supported.
## Changes in Zulip 2.2
**Feature level 4**
* `jitsi_server_url`, `development_environment`, `server_generation`,
`password_min_length`, `password_min_guesses`, `max_file_upload_size_mib`,
`max_avatar_file_size_mib`, `server_inline_image_preview`,
`server_inline_url_embed_preview`, `server_avatar_changes_disabled` and
`server_name_changes_disabled` fields are now available via
`POST /register` to make them accessible to all the clients;
they were only internally available to Zulip's web app prior to this.
**Feature level 3**:
* `zulip_version` and `zulip_feature_level` are always returned

View File

@ -29,7 +29,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"
#
# Changes should be accompanied by documentation explaining what the
# new level means in templates/zerver/api/changelog.md.
API_FEATURE_LEVEL = 3
API_FEATURE_LEVEL = 4
# 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

View File

@ -170,6 +170,17 @@ def fetch_initial_state_data(user_profile: UserProfile,
state['zulip_plan_is_not_limited'] = realm.plan_type != Realm.LIMITED
state['upgrade_text_for_wide_organization_logo'] = str(Realm.UPGRADE_TEXT_STANDARD)
state['realm_default_external_accounts'] = DEFAULT_EXTERNAL_ACCOUNTS
state['jitsi_server_url'] = settings.JITSI_SERVER_URL
state['development_environment'] = settings.DEVELOPMENT
state['server_generation'] = settings.SERVER_GENERATION
state['password_min_length'] = settings.PASSWORD_MIN_LENGTH
state['password_min_guesses'] = settings.PASSWORD_MIN_GUESSES
state['max_file_upload_size_mib'] = settings.MAX_FILE_UPLOAD_SIZE
state['max_avatar_file_size_mib'] = settings.MAX_AVATAR_FILE_SIZE
state['server_inline_image_preview'] = settings.INLINE_IMAGE_PREVIEW
state['server_inline_url_embed_preview'] = settings.INLINE_URL_EMBED_PREVIEW
state['server_avatar_changes_disabled'] = settings.AVATAR_CHANGES_DISABLED
state['server_name_changes_disabled'] = settings.NAME_CHANGES_DISABLED
if realm.notifications_stream and not realm.notifications_stream.deactivated:
notifications_stream = realm.notifications_stream

View File

@ -246,26 +246,15 @@ def home_real(request: HttpRequest) -> HttpResponse:
# These end up in a global JavaScript Object named 'page_params'.
page_params = dict(
# Server settings.
development_environment = settings.DEVELOPMENT,
debug_mode = settings.DEBUG,
test_suite = settings.TEST_SUITE,
poll_timeout = settings.POLL_TIMEOUT,
insecure_desktop_app = insecure_desktop_app,
login_page = settings.HOME_NOT_LOGGED_IN,
root_domain_uri = settings.ROOT_DOMAIN_URI,
max_file_upload_size_mib = settings.MAX_FILE_UPLOAD_SIZE,
max_avatar_file_size_mib = settings.MAX_AVATAR_FILE_SIZE,
server_generation = settings.SERVER_GENERATION,
save_stacktraces = settings.SAVE_FRONTEND_STACKTRACES,
warn_no_email = settings.WARN_NO_EMAIL,
server_inline_image_preview = settings.INLINE_IMAGE_PREVIEW,
server_inline_url_embed_preview = settings.INLINE_URL_EMBED_PREVIEW,
password_min_length = settings.PASSWORD_MIN_LENGTH,
password_min_guesses = settings.PASSWORD_MIN_GUESSES,
jitsi_server_url = settings.JITSI_SERVER_URL,
search_pills_enabled = settings.SEARCH_PILLS_ENABLED,
server_avatar_changes_disabled = settings.AVATAR_CHANGES_DISABLED,
server_name_changes_disabled = settings.NAME_CHANGES_DISABLED,
# Misc. extra data.
have_initial_messages = user_has_messages,