Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

api: Add "user_settings" object to '/register' response.

Sahil Batra84742a040e7d
diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md
index 370e7d5b7d3..0962f19db07 100644
--- a/templates/zerver/api/changelog.md
+++ b/templates/zerver/api/changelog.md
@@ -23,6 +23,8 @@ below features are supported.
`update_global_notifications` are sent only when `user_settings_object`
is not included in the `client_capabilities` when registering the
event queue.
+* [`POST /register`](/api/register-queue): Added `user_settings` field
+ in the response, which is a dictionary containing all the user settings.
**Feature level 88**
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 9ac5baf6993..ba6fd0bb832 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -524,6 +524,20 @@ def fetch_initial_state_data(
state[notification] = getattr(settings_user, notification)
state["available_notification_sounds"] = get_available_notification_sounds()
+ if want("user_settings"):
+ state["user_settings"] = {}
+
+ for prop in UserProfile.property_types:
+ state["user_settings"][prop] = getattr(settings_user, prop)
+ for notification in UserProfile.notification_setting_types:
+ state["user_settings"][notification] = getattr(settings_user, notification)
+
+ state["user_settings"]["emojiset_choices"] = UserProfile.emojiset_choices()
+ state["user_settings"]["timezone"] = settings_user.timezone
+ state["user_settings"][
+ "available_notification_sounds"
+ ] = get_available_notification_sounds()
+
if want("user_status"):
# We require creating an account to access statuses.
state["user_status"] = {} if user_profile is None else get_user_info_dict(realm_id=realm.id)
@@ -1112,6 +1126,7 @@ def apply_event(
or event["property"] in UserProfile.notification_setting_types
)
state[event["property"]] = event["value"]
+ state["user_settings"][event["property"]] = event["value"]
elif event["type"] == "invites_changed":
pass
elif event["type"] == "user_group":
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index f5b73b3f2ff..e80ca57c3e1 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -9015,6 +9015,242 @@ paths:
The [emoji type](/api/add-reaction#parameters) for the emoji associated with the new status.
**Changes**: New in Zulip 5.0 (feature level 86).
+ user_settings:
+ type: object
+ description: |
+ Present if `user_settings` is present in `fetch_event_types`.
+
+ A dictionary containing the user's personal settings.
+
+ **Changes**: New in Zulip 5.0 (feature level 89).
+ additionalProperties: false
+ properties:
+ twenty_four_hour_time:
+ type: boolean
+ description: |
+ Whether time should be [displayed in 24-hour notation](/help/change-the-time-format).
+ dense_mode:
+ type: boolean
+ description: |
+ This setting has no effect at present. It is reserved for use in controlling
+ the default font size in Zulip.
+ starred_message_counts:
+ type: boolean
+ description: |
+ Whether clients should display the [number of starred
+ messages](/help/star-a-message#display-the-number-of-starred-messages).
+ fluid_layout_width:
+ type: boolean
+ description: |
+ Whether to use the [maximum available screen width](/help/enable-full-width-display)
+ for the web app's center panel (message feed, recent topics) on wide screens.
+ high_contrast_mode:
+ type: boolean
+ description: |
+ This setting is reserved for use to control variations in Zulip's design
+ to help visually impaired users.
+ color_scheme:
+ type: integer
+ description: |
+ Controls which [color theme](/help/night-mode) to use.
+
+ * 1 - Automatic
+ * 2 - Night mode
+ * 3 - Day mode
+
+ Automatic detection is implementing using the standard `prefers-color-scheme`
+ media query.
+ translate_emoticons:
+ type: boolean
+ description: |
+ Whether to [translate emoticons to emoji](/help/enable-emoticon-translations)
+ in messages the user sends.
+ default_language:
+ type: string
+ description: |
+ What [default language](/help/change-your-language) to use for the account.
+
+ This controls both the Zulip UI as well as email notifications sent to the user.
+
+ The value needs to be a standard language code that the Zulip server has
+ translation data for; for example, `"en"` for English or `"de"` for German.
+ default_view:
+ type: string
+ description: |
+ The [default view](/help/change-default-view) used when opening a new
+ Zulip web app window or hitting the `Esc` keyboard shortcut repeatedly.
+
+ * "recent_topics" - Recent topics view
+ * "all_messages" - All messages view
+ left_side_userlist:
+ type: boolean
+ description: |
+ Whether the users list on left sidebar in narrow windows.
+
+ This feature is not heavily used and is likely to be reworked.
+ emojiset:
+ type: string
+ description: |
+ The user's configured [emoji set](/help/emoji-and-emoticons#use-emoticons),
+ used to display emoji to the user everything they appear in the UI.
+
+ * "google" - Google modern
+ * "google-blob" - Google classic
+ * "twitter" - Twitter
+ * "text" - Plain text
+ demote_inactive_streams:
+ type: integer
+ description: |
+ Whether to [demote inactive streams](/help/manage-inactive-streams) in the left sidebar.
+
+ * 1 - Automatic
+ * 2 - Always
+ * 3 - Never
+ timezone:
+ type: string
+ description: |
+ The user's [configured timezone](/help/change-your-timezone).
+
+ Timezone values supported by the server are served at
+ [/static/generated/timezones.json](/static/generated/timezones.json).
+ enter_sends:
+ type: boolean
+ description: |
+ Whether the user setting for [sending on pressing Enter](/help/enable-enter-to-send)
+ in the compose box is enabled.
+ enable_drafts_synchronization:
+ type: boolean
+ description: |
+ A boolean parameter to control whether synchronizing drafts is enabled for
+ the user. When synchronization is disabled, all drafts stored in the server
+ will be automatically deleted from the server.
+
+ This does not do anything (like sending events) to delete local copies of
+ drafts stored in clients.
+ enable_stream_desktop_notifications:
+ type: boolean
+ description: |
+ Enable visual desktop notifications for stream messages.
+ enable_stream_email_notifications:
+ type: boolean
+ description: |
+ Enable email notifications for stream messages.
+ enable_stream_push_notifications:
+ type: boolean
+ description: |
+ Enable mobile notifications for stream messages.
+ enable_stream_audible_notifications:
+ type: boolean
+ description: |
+ Enable audible desktop notifications for stream messages.
+ notification_sound:
+ type: string
+ description: |
+ Notification sound name.
+ enable_desktop_notifications:
+ type: boolean
+ description: |
+ Enable visual desktop notifications for private messages and @-mentions.
+ enable_sounds:
+ type: boolean
+ description: |
+ Enable audible desktop notifications for private messages and
+ @-mentions.
+ email_notifications_batching_period_seconds:
+ type: integer
+ description: |
+ The duration (in seconds) for which the server should wait to batch
+ email notifications before sending them.
+ enable_offline_email_notifications:
+ type: boolean
+ description: |
+ Enable email notifications for private messages and @-mentions received
+ when the user is offline.
+ enable_offline_push_notifications:
+ type: boolean
+ description: |
+ Enable mobile notification for private messages and @-mentions received
+ when the user is offline.
+ enable_online_push_notifications:
+ type: boolean
+ description: |
+ Enable mobile notification for private messages and @-mentions received
+ when the user is online.
+ enable_digest_emails:
+ type: boolean
+ description: |
+ Enable digest emails when the user is away.
+ enable_marketing_emails:
+ type: boolean
+ description: |
+ Enable marketing emails. Has no function outside Zulip Cloud.
+ enable_login_emails:
+ type: boolean
+ description: |
+ Enable email notifications for new logins to account.
+ message_content_in_email_notifications:
+ type: boolean
+ description: |
+ Include the message's content in email notifications for new messages.
+ pm_content_in_desktop_notifications:
+ type: boolean
+ description: |
+ Include content of private messages in desktop notifications.
+ wildcard_mentions_notify:
+ type: boolean
+ description: |
+ Whether wildcard mentions (E.g. @**all**) should send notifications
+ like a personal mention.
+ desktop_icon_count_display:
+ type: integer
+ description: |
+ Unread count summary (appears in desktop sidebar and browser tab)
+
+ * 1 - All unreads
+ * 2 - Private messages and mentions
+ * 3 - None
+ realm_name_in_notifications:
+ type: boolean
+ description: |
+ Include organization name in subject of message notification emails.
+ presence_enabled:
+ type: boolean
+ description: |
+ Display the presence status to other users when online.
+ available_notification_sounds:
+ type: array
+ items:
+ type: string
+ description: |
+ Array containing the names of the notification sound options
+ supported by this Zulip server. Only relevant to support UI
+ for configuring notification sounds.
+ emojiset_choices:
+ description: |
+ Array of dictionaries where each dictionary describes an emojiset
+ supported by this version of the Zulip server.
+
+ Only relevant to clients with configuration UI for choosing an emojiset;
+ the currently selected emojiset is available in the `emojiset` key.
+
+ See [PATCH /settings](/api/update-settings) for details on
+ the meaning of this setting.
+ type: array
+ items:
+ type: object
+ description: |
+ Object describing a emojiset.
+ additionalProperties: false
+ properties:
+ key:
+ type: string
+ description: |
+ The key or the name of the emojiset which will be the value
+ of `emojiset` if this emojiset is chosen.
+ text:
+ type: string
+ description: |
+ The text describing the emojiset.
has_zoom_token:
type: boolean
description: |
diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.py
index 0540f8311bc..7c577d67529 100644
--- a/zerver/tests/test_event_system.py
+++ b/zerver/tests/test_event_system.py
@@ -1013,6 +1013,7 @@ class FetchQueriesTest(ZulipTestCase):
update_display_settings=0,
update_global_notifications=0,
update_message_flags=5,
+ user_settings=0,
user_status=1,
video_calls=0,
giphy=0,
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index 335a0889baa..2cb13046b88 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -234,6 +234,7 @@ class HomeTest(ZulipTestCase):
"unsubscribed",
"upgrade_text_for_wide_organization_logo",
"user_id",
+ "user_settings",
"user_status",
"warn_no_email",
"webpack_public_path",