diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index 75076c0e8a..e211c88c87 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -10,6 +10,12 @@ below features are supported. ## 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**: * [`POST /messages/{message_id}/reactions`](/api/add-emoji-reaction): diff --git a/zerver/lib/events.py b/zerver/lib/events.py index a7136d7d29..7209706907 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -97,6 +97,10 @@ def fetch_initial_state_data(user_profile: UserProfile, else: 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'): state['alert_words'] = user_alert_words(user_profile) @@ -310,10 +314,6 @@ def fetch_initial_state_data(user_profile: UserProfile, if want('user_status'): 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 def apply_events(state: Dict[str, Any], events: Iterable[Dict[str, Any]], diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 539bd4f362..495a87fb6a 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -2587,6 +2587,14 @@ paths: type: integer description: | 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: { "last_event_id": -1, @@ -2605,7 +2613,9 @@ paths: "source_url": "/user_avatars/1/emoji/images/1.png" } }, - "result": "success" + "result": "success", + "zulip_feature_level": 2, + "zulip_version": "2.1.0" } /server_settings: get: diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 36b0896ea6..f059616213 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -3662,7 +3662,6 @@ class FetchQueriesTest(ZulipTestCase): update_global_notifications=0, update_message_flags=5, user_status=1, - zulip_version=0, ) wanted_event_types = {