api: Always return zulip_version/zulip_feature_level.

We no longer make these conditional to simplify writing clients;
there's no cost to including them, and a real cost to not doing so.
This commit is contained in:
Steve Howell 2020-04-29 10:39:39 +00:00 committed by Tim Abbott
parent 1b8ab92058
commit 2c63130195
4 changed files with 21 additions and 6 deletions

View File

@ -10,6 +10,12 @@ below features are supported.
## Changes in Zulip 2.2 ## Changes in Zulip 2.2
**Feature level 3**:
* `zulip_version` and `zulip_feature_level` are always returned
in `POST /register`; previously they were only returned if `event_types`
included `zulip_version`.
**Feature level 2**: **Feature level 2**:
* [`POST /messages/{message_id}/reactions`](/api/add-emoji-reaction): * [`POST /messages/{message_id}/reactions`](/api/add-emoji-reaction):

View File

@ -97,6 +97,10 @@ def fetch_initial_state_data(user_profile: UserProfile,
else: else:
want = set(event_types).__contains__ want = set(event_types).__contains__
# Show the version info unconditionally.
state['zulip_version'] = ZULIP_VERSION
state['zulip_feature_level'] = API_FEATURE_LEVEL
if want('alert_words'): if want('alert_words'):
state['alert_words'] = user_alert_words(user_profile) state['alert_words'] = user_alert_words(user_profile)
@ -310,10 +314,6 @@ def fetch_initial_state_data(user_profile: UserProfile,
if want('user_status'): if want('user_status'):
state['user_status'] = get_user_info_dict(realm_id=realm.id) state['user_status'] = get_user_info_dict(realm_id=realm.id)
if want('zulip_version'):
state['zulip_version'] = ZULIP_VERSION
state['zulip_feature_level'] = API_FEATURE_LEVEL
return state return state
def apply_events(state: Dict[str, Any], events: Iterable[Dict[str, Any]], def apply_events(state: Dict[str, Any], events: Iterable[Dict[str, Any]],

View File

@ -2587,6 +2587,14 @@ paths:
type: integer type: integer
description: | description: |
The initial value of `last_event_id` to pass to `GET /api/v1/events`. The initial value of `last_event_id` to pass to `GET /api/v1/events`.
zulip_feature_level:
type: integer
description: |
The server's current [Zulip feature level](/api/changelog).
zulip_version:
type: string
description: |
The server's version.
- example: - example:
{ {
"last_event_id": -1, "last_event_id": -1,
@ -2605,7 +2613,9 @@ paths:
"source_url": "/user_avatars/1/emoji/images/1.png" "source_url": "/user_avatars/1/emoji/images/1.png"
} }
}, },
"result": "success" "result": "success",
"zulip_feature_level": 2,
"zulip_version": "2.1.0"
} }
/server_settings: /server_settings:
get: get:

View File

@ -3662,7 +3662,6 @@ class FetchQueriesTest(ZulipTestCase):
update_global_notifications=0, update_global_notifications=0,
update_message_flags=5, update_message_flags=5,
user_status=1, user_status=1,
zulip_version=0,
) )
wanted_event_types = { wanted_event_types = {