Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
register: Send user_settings in response based on client capabilities.
Sahil Batrae6f828a8e254
diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.mdindex 0962f19db07..d18642d505f 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` fieldin 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.pyindex ba6fd0bb832..4cbf6a23262 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.pyindex bc7f79cdc29..f032056ec56 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.yamlindex e80ca57c3e1..0bfd85dee4e 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: falseproperties:twenty_four_hour_time:@@ -9275,222 +9278,379 @@ paths:**Changes**: Added in Zulip 4.0 (feature level 47).enable_desktop_notifications:+ deprecated: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.enable_digest_emails:+ deprecated: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.enable_login_emails:+ deprecated: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.enable_marketing_emails:+ deprecated: truetype: booleandescription: |- 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 onthe 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: truetype: integerdescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.enable_sounds:+ deprecated: truetype: booleandescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.wildcard_mentions_notify:+ deprecated: truetype: booleandescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.notification_sound:+ deprecated: truetype: stringdescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe 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: truetype: integerdescription: |- 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 onthe 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: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.presence_enabled:+ deprecated: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.available_notification_sounds:+ deprecated: truetype: arrayitems:type: stringdescription: |- 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 bythis Zulip server. Only relevant to support UI for configuring notificationsounds.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.color_scheme:+ deprecated: truetype: integerdescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.default_language:+ deprecated: truetype: stringdescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.demote_inactive_streams:+ deprecated: truetype: integerdescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.dense_mode:+ deprecated: truetype: booleandescription: |- 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 experimentalfeature that is only available in development environments.See [PATCH /settings](/api/update-settings) for details onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.emojiset:+ deprecated: truetype: stringdescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.enable_drafts_synchronization:+ deprecated: truetype: booleandescription: |Present if `update_display_settings` is present in `fetch_event_types`.@@ -9501,20 +9661,30 @@ paths:See [PATCH /settings](/api/update-settings) for details onthe 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: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.default_view:+ deprecated: truetype: stringdescription: |- 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, representedas the URL suffix after `#` to be rendered when Zulip loads.@@ -9523,19 +9693,31 @@ paths:See [PATCH /settings](/api/update-settings) for details onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.high_contrast_mode:+ deprecated: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.left_side_userlist:+ deprecated: truetype: booleandescription: |- 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 displayedon 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.starred_message_counts:+ deprecated: truetype: booleandescription: |- 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 tobe displayed similar to unread counts.See [PATCH /settings](/api/update-settings) for details onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.timezone:+ deprecated: truetype: stringdescription: |- 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 displaythe user's timezone to other users.See [PATCH /settings](/api/update-settings) for details onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.translate_emoticons:+ deprecated: truetype: booleandescription: |- 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 emojiin the Zulip compose box.See [PATCH /settings](/api/update-settings) for details onthe 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: truetype: booleandescription: |- 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 onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.emojiset_choices:+ deprecated: truedescription: |- 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 emojisetsupported by this version of the Zulip server.@@ -9595,6 +9807,9 @@ paths:See [PATCH /settings](/api/update-settings) for details onthe meaning of this setting.++ **Changes**: Deprecated in Zulip 5.0 (feature level 89), clients should+ use `user_settings` dictionary instead.type: arrayitems:type: object@@ -10467,14 +10682,19 @@ paths:Whether the current user is a [guest user](/help/roles-and-permissions).enter_sends:+ deprecated: truetype: booleandescription: |- 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 presentin 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.pyindex 7c577d67529..3c71c9b867a 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: