Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user_settings: Add settings to configure sending typing notifications.
Dinesh6d2b8f5ca963
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.jsindex bd758a3435e..1905cc0b9ee 100644--- a/static/js/server_events_dispatch.js+++ b/static/js/server_events_dispatch.js@@ -583,6 +583,8 @@ export function dispatch_normal_event(event) {"twenty_four_hour_time","translate_emoticons","starred_message_counts",+ "send_stream_typing_notifications",+ "send_private_typing_notifications",];if (user_display_settings.includes(event.property)) {diff --git a/static/js/settings.js b/static/js/settings.jsindex a00e6a1ddf9..305b5029610 100644--- a/static/js/settings.js+++ b/static/js/settings.js@@ -48,6 +48,12 @@ function setup_settings_label() {presence_enabled: $t({defaultMessage: "Display my availability to other users when online",}),+ send_stream_typing_notifications: $t({+ defaultMessage: "Let subscribers see when I'm typing messages in streams",+ }),+ send_private_typing_notifications: $t({+ defaultMessage: "Let recipients see when I'm typing private messages",+ }),...settings_config.notification_settings_labels,...settings_config.display_settings_labels,diff --git a/static/js/settings_account.js b/static/js/settings_account.jsindex c0728077514..7ee0260619e 100644--- a/static/js/settings_account.js+++ b/static/js/settings_account.js@@ -682,11 +682,15 @@ export function set_up() {);});- $("#user_presence_enabled").on("change", (e) => {+ $("#privacy_settings_box").on("change", "input", (e) => {e.preventDefault();e.stopPropagation();- const data = {presence_enabled: $("#user_presence_enabled").prop("checked")};+ const input_elem = $(e.currentTarget);+ const setting_name = input_elem.attr("name");+ const checked = input_elem.prop("checked");++ const data = {[setting_name]: checked};settings_ui.do_settings_change(channel.patch,"/json/settings",diff --git a/static/js/user_settings.ts b/static/js/user_settings.tsindex 6acf6bc3c28..20832e03476 100644--- a/static/js/user_settings.ts+++ b/static/js/user_settings.ts@@ -33,6 +33,8 @@ export type UserSettingsType = {translate_emoticons: boolean;twenty_four_hour_time: boolean;wildcard_mentions_notify: boolean;+ send_stream_typing_notifications: boolean;+ send_private_typing_notifications: boolean;};export let user_settings = {} as UserSettingsType;diff --git a/static/templates/settings/account_settings.hbs b/static/templates/settings/account_settings.hbsindex f20b6ad5a69..49960267466 100644--- a/static/templates/settings/account_settings.hbs+++ b/static/templates/settings/account_settings.hbs@@ -105,6 +105,18 @@label=settings_label.presence_enabledhelp_link="/help/status-and-availability"prefix="user_"}}+ {{> settings_checkbox+ setting_name="send_private_typing_notifications"+ is_checked=settings_object.send_private_typing_notifications+ label=settings_label.send_private_typing_notifications+ }}+ {{#if page_params.development_environment }}+ {{> settings_checkbox+ setting_name="send_stream_typing_notifications"+ is_checked=settings_object.send_stream_typing_notifications+ label=settings_label.send_stream_typing_notifications+ }}+ {{/if}}</div></div>diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.mdindex 643f0cdec87..8103d752a42 100644--- a/templates/zerver/api/changelog.md+++ b/templates/zerver/api/changelog.md@@ -11,6 +11,18 @@ below features are supported.## Changes in Zulip 5.0+**Feature level 105**++* [`POST /register`](/api/register-queue), [`PATCH+ /settings`](/api/update-settings), [`PATCH+ /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults):+ Added two new settings: `send_private_typing_notifications` controls+ whether clients should send typing notifications when composing+ private messages, and `send_stream_typing_notifications` does the+ same when composing stream messages. Only+ `send_private_typing_notifications` has a functional effect, as+ stream-level typing notifications are not a finished feature.+**Feature level 104*** [`PATCH /realm`]: Added `string_id` parameter for changing andiff --git a/version.py b/version.pyindex 5d2d4b2aef5..cb4fd06ebb7 100644--- a/version.py+++ b/version.py@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"# Changes should be accompanied by documentation explaining what the# new level means in templates/zerver/api/changelog.md, as well as# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.-API_FEATURE_LEVEL = 104+API_FEATURE_LEVEL = 105# Bump the minor PROVISION_VERSION to indicate that folks should provision# only when going from an old version of the code to a newer version. Bumpdiff --git a/zerver/migrations/0362_send_typing_notifications_user_setting.py b/zerver/migrations/0362_send_typing_notifications_user_setting.pynew file mode 100644index 00000000000..72ffd77bb75--- /dev/null+++ b/zerver/migrations/0362_send_typing_notifications_user_setting.py@@ -0,0 +1,33 @@+# Generated by Django 3.2.7 on 2021-10-03 07:09++from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("zerver", "0361_realm_create_web_public_stream_policy"),+ ]++ operations = [+ migrations.AddField(+ model_name="realmuserdefault",+ name="send_private_typing_notifications",+ field=models.BooleanField(default=True),+ ),+ migrations.AddField(+ model_name="realmuserdefault",+ name="send_stream_typing_notifications",+ field=models.BooleanField(default=True),+ ),+ migrations.AddField(+ model_name="userprofile",+ name="send_private_typing_notifications",+ field=models.BooleanField(default=True),+ ),+ migrations.AddField(+ model_name="userprofile",+ name="send_stream_typing_notifications",+ field=models.BooleanField(default=True),+ ),+ ]diff --git a/zerver/models.py b/zerver/models.pyindex e381953440a..d06ec3a3ff0 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -1436,6 +1436,10 @@ class UserBaseSettings(models.Model):# Whether or not the user wants to sync their drafts.enable_drafts_synchronization = models.BooleanField(default=True)+ # Privacy settings+ send_stream_typing_notifications: bool = models.BooleanField(default=True)+ send_private_typing_notifications: bool = models.BooleanField(default=True)+display_settings_legacy = dict(color_scheme=int,default_language=str,@@ -1481,7 +1485,15 @@ class UserBaseSettings(models.Model):} # Add new notifications settings here.# Define the types of the various automatically managed properties- property_types = {**display_settings_legacy, **notification_setting_types}+ property_types = {+ **display_settings_legacy,+ **notification_setting_types,+ **dict(+ # Add new general settings here.+ send_stream_typing_notifications=bool,+ send_private_typing_notifications=bool,+ ),+ }class Meta:abstract = Truediff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex e55ed2a89e0..91d47c96343 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -7864,6 +7864,26 @@ paths:schema:type: booleanexample: true+ - name: send_private_typing_notifications+ in: query+ description: |+ Whether [typing notifications](/help/status-and-availability#typing-notifications) be sent when composing+ private messages.++ **Changes**: New in Zulip 5.0 (feature level 105).+ schema:+ type: boolean+ example: true+ - name: send_stream_typing_notifications+ in: query+ description: |+ Whether [typing notifications](/help/status-and-availability#typing-notifications) be sent when composing+ stream messages.++ **Changes**: New in Zulip 5.0 (feature level 105).+ schema:+ type: boolean+ example: trueresponses:"200":description: Success@@ -9722,6 +9742,24 @@ paths:type: stringdescription: |The text describing the emoji set.+ send_private_typing_notifications:+ type: boolean+ description: |+ Whether the user has chosen to send [typing+ notifications](/help/status-and-availability#typing-notifications)+ when composing private messages. The client should send typing+ notifications for private messages if and only if this setting is enabled.++ **Changes**: New in Zulip 5.0 (feature level 105).+ send_stream_typing_notifications:+ type: boolean+ description: |+ Whether the user has chosen to send [typing+ notifications](/help/status-and-availability#typing-notifications)+ when composing stream messages. The client should send typing+ notifications for stream messages if and only if this setting is enabled.++ **Changes**: New in Zulip 5.0 (feature level 105).has_zoom_token:type: booleandescription: |@@ -11376,6 +11414,20 @@ paths:type: stringdescription: |The text describing the emoji set.+ send_private_typing_notifications:+ type: boolean+ description: |+ Whether [typing notifications](/help/status-and-availability#typing-notifications) be sent when composing+ private messages.++ **Changes**: New in Zulip 5.0 (feature level 105).+ send_stream_typing_notifications:+ type: boolean+ description: |+ Whether [typing notifications](/help/status-and-availability#typing-notifications) be sent when composing+ stream messages.++ **Changes**: New in Zulip 5.0 (feature level 105).realm_users:type: arraydescription: |@@ -12409,6 +12461,26 @@ paths:schema:type: booleanexample: true+ - name: send_private_typing_notifications+ in: query+ description: |+ Whether [typing notifications](/help/status-and-availability#typing-notifications) be sent when composing+ private messages.++ **Changes**: New in Zulip 5.0 (feature level 105).+ schema:+ type: boolean+ example: true+ - name: send_stream_typing_notifications+ in: query+ description: |+ Whether [typing notifications](/help/status-and-availability#typing-notifications) be sent when composing+ stream messages.++ **Changes**: New in Zulip 5.0 (feature level 105).+ schema:+ type: boolean+ example: trueresponses:"200":description: Successdiff --git a/zerver/views/realm.py b/zerver/views/realm.pyindex ca228370903..0dc25e60e4f 100644--- a/zerver/views/realm.py+++ b/zerver/views/realm.py@@ -395,6 +395,8 @@ def update_realm_user_settings_defaults(json_validator=check_int, default=None),twenty_four_hour_time: Optional[bool] = REQ(json_validator=check_bool, default=None),+ send_stream_typing_notifications: Optional[bool] = REQ(json_validator=check_bool, default=None),+ send_private_typing_notifications: Optional[bool] = REQ(json_validator=check_bool, default=None),) -> HttpResponse:if notification_sound is not None or email_notifications_batching_period_seconds is not None:check_settings_values(notification_sound, email_notifications_batching_period_seconds)diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.pyindex 099ef6a5c20..9f51255c942 100644--- a/zerver/views/user_settings.py+++ b/zerver/views/user_settings.py@@ -189,6 +189,10 @@ def json_change_settings(realm_name_in_notifications: Optional[bool] = REQ(json_validator=check_bool, default=None),presence_enabled: Optional[bool] = REQ(json_validator=check_bool, default=None),enter_sends: Optional[bool] = REQ(json_validator=check_bool, default=None),+ send_private_typing_notifications: Optional[bool] = REQ(+ json_validator=check_bool, default=None+ ),+ send_stream_typing_notifications: Optional[bool] = REQ(json_validator=check_bool, default=None),) -> HttpResponse:if (default_language is not None