diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index 0962f19db0..d18642d505 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -25,6 +25,10 @@ below features are supported. event queue. * [`POST /register`](/api/register-queue): Added `user_settings` field in the response, which is a dictionary containing all the user settings. +* [`POST /register`](/api/register-queue): User's personal settings in + the top-level object are included in response only when `user_settings_object` + is not included in the `client_capabilities` when registering the event + queue. **Feature level 88** diff --git a/zerver/lib/events.py b/zerver/lib/events.py index ba6fd0bb83..4cbf6a2326 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -105,6 +105,7 @@ def fetch_initial_state_data( queue_id: Optional[str] = "", client_gravatar: bool = False, user_avatar_url_field_optional: bool = False, + user_settings_object: bool = False, slim_presence: bool = False, include_subscribers: bool = True, include_streams: bool = True, @@ -513,13 +514,13 @@ def fetch_initial_state_data( if want("stop_words"): state["stop_words"] = read_stop_words() - if want("update_display_settings"): + if want("update_display_settings") and not user_settings_object: for prop in UserProfile.property_types: state[prop] = getattr(settings_user, prop) state["emojiset_choices"] = UserProfile.emojiset_choices() state["timezone"] = settings_user.timezone - if want("update_global_notifications"): + if want("update_global_notifications") and not user_settings_object: for notification in UserProfile.notification_setting_types: state[notification] = getattr(settings_user, notification) state["available_notification_sounds"] = get_available_notification_sounds() @@ -1276,6 +1277,7 @@ def do_events_register( queue_id=queue_id, client_gravatar=client_gravatar, user_avatar_url_field_optional=user_avatar_url_field_optional, + user_settings_object=user_settings_object, slim_presence=slim_presence, include_subscribers=include_subscribers, include_streams=include_streams, diff --git a/zerver/lib/home.py b/zerver/lib/home.py index bc7f79cdc2..f032056ec5 100644 --- a/zerver/lib/home.py +++ b/zerver/lib/home.py @@ -164,6 +164,7 @@ def build_page_params_for_home_page_load( queue_id=None, client_gravatar=False, user_avatar_url_field_optional=client_capabilities["user_avatar_url_field_optional"], + user_settings_object=client_capabilities["user_settings_object"], slim_presence=False, include_subscribers=False, include_streams=False, diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index e80ca57c3e..0bfd85dee4 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -9022,7 +9022,10 @@ paths: A dictionary containing the user's personal settings. - **Changes**: New in Zulip 5.0 (feature level 89). + **Changes**: New in Zulip 5.0 (feature level 89). Previously, + these settings appeared in the top-level object, where they are + available for clients without the `user_settings_object` client + capability for backwards-compatibility. additionalProperties: false properties: twenty_four_hour_time: @@ -9275,222 +9278,379 @@ paths: **Changes**: Added in Zulip 4.0 (feature level 47). enable_desktop_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_digest_emails: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_login_emails: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_marketing_emails: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. email_notifications_batching_period_seconds: + deprecated: true type: integer description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_offline_email_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_offline_push_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_online_push_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_sounds: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_stream_desktop_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_stream_email_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_stream_push_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_stream_audible_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. wildcard_mentions_notify: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. message_content_in_email_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. notification_sound: + deprecated: true type: string description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. pm_content_in_desktop_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. desktop_icon_count_display: + deprecated: true type: integer description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. realm_name_in_notifications: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. presence_enabled: + deprecated: true type: boolean description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. The current value of this global notification setting for the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. available_notification_sounds: + deprecated: true type: array items: type: string description: | - Present if `update_global_notifications` is present in `fetch_event_types`. + Present if `update_global_notifications` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in their + client_capabilities` when registering the event queue. Array containing the names of the notification sound options supported by this Zulip server. Only relevant to support UI for configuring notification sounds. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. color_scheme: + deprecated: true type: integer description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. The color scheme selected by the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. default_language: + deprecated: true type: string description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. The default language chosen by the user. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. demote_inactive_streams: + deprecated: true type: integer description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Whether the user has chosen to demote inactive streams. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. dense_mode: + deprecated: true type: boolean description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Whether the user has switched on dense mode. Dense mode is an experimental feature that is only available in development environments. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. emojiset: + deprecated: true type: string description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. The name of the emojiset that the user has chosen. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. enable_drafts_synchronization: + deprecated: true type: boolean description: | Present if `update_display_settings` is present in `fetch_event_types`. @@ -9501,20 +9661,30 @@ paths: See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. - **Changes**: New in Zulip 5.0 (feature level 87). + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. New in Zulip 5.0 (feature level 87). fluid_layout_width: + deprecated: true type: boolean description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Whether the user has chosen for the layout width to be fluid. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. default_view: + deprecated: true type: string description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. The [default view](/help/change-default-view) in Zulip, represented as the URL suffix after `#` to be rendered when Zulip loads. @@ -9523,19 +9693,31 @@ paths: See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. high_contrast_mode: + deprecated: true type: boolean description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Whether has switched on high contrast mode. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. left_side_userlist: + deprecated: true type: boolean description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Whether the user has chosen for the userlist to be displayed on the left side of the screen (for desktop app and web app) in narrow @@ -9543,49 +9725,79 @@ paths: See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. starred_message_counts: + deprecated: true type: boolean description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Whether the user has chosen the number of starred messages to be displayed similar to unread counts. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. timezone: + deprecated: true type: string description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. The timezone configured for the user. This is used primarily to display the user's timezone to other users. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. translate_emoticons: + deprecated: true type: boolean description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Whether the user has chosen for emoticons to be translated into emoji in the Zulip compose box. See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. twenty_four_hour_time: + deprecated: true type: boolean description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Whether the user has chosen a twenty four hour time display (true) or a twelve hour one (false). See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. emojiset_choices: + deprecated: true description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Array of dictionaries where each dictionary describes an emojiset supported by this version of the Zulip server. @@ -9595,6 +9807,9 @@ paths: See [PATCH /settings](/api/update-settings) for details on the meaning of this setting. + + **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should + use `user_settings` dictionary instead. type: array items: type: object @@ -10467,14 +10682,19 @@ paths: Whether the current user is a [guest user](/help/roles-and-permissions). enter_sends: + deprecated: true type: boolean description: | - Present if `update_display_settings` is present in `fetch_event_types`. + Present if `update_display_settings` is present in `fetch_event_types` + and only for clients that did not include `user_settings_object` in + their client_capabilities` when registering the event queue. Whether the user setting for [sending on pressing Enter](/help/enable-enter-to-send) in the compose box is enabled. - **Changes**: Prior to Zulip 5.0 (feature level 84) this field was present + **Changes**: Deprecated in Zulip 5.0 (feature level 87), clients should + use `user_settings` dictionary instead. + Prior to Zulip 5.0 (feature level 84) this field was present in response if 'realm_user' was present in `fetch_event_types`, not `update_display_settings`. user_id: diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.py index 7c577d6752..3c71c9b867 100644 --- a/zerver/tests/test_event_system.py +++ b/zerver/tests/test_event_system.py @@ -547,6 +547,32 @@ class FetchInitialStateDataTest(ZulipTestCase): else: self.assertFalse("avatar_url" in user_dict) + def test_user_settings_based_on_client_capabilities(self) -> None: + hamlet = self.example_user("hamlet") + result = fetch_initial_state_data( + user_profile=hamlet, + user_settings_object=True, + ) + self.assertIn("user_settings", result) + for prop in UserProfile.property_types: + self.assertNotIn(prop, result) + self.assertIn(prop, result["user_settings"]) + for prop in UserProfile.notification_setting_types: + self.assertNotIn(prop, result) + self.assertIn(prop, result["user_settings"]) + + result = fetch_initial_state_data( + user_profile=hamlet, + user_settings_object=False, + ) + self.assertIn("user_settings", result) + for prop in UserProfile.property_types: + self.assertIn(prop, result) + self.assertIn(prop, result["user_settings"]) + for prop in UserProfile.notification_setting_types: + self.assertIn(prop, result) + self.assertIn(prop, result["user_settings"]) + class ClientDescriptorsTest(ZulipTestCase): def test_get_client_info_for_all_public_streams(self) -> None: