From 764083d31b99c1409043bc65ec9bfe49d309d90e Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Mon, 9 Sep 2024 16:21:38 +0530 Subject: [PATCH] settings: Add 'allow_private_data_export' user setting. This commit adds a user-setting to allow users to decide whether to let administrators export their private data. Fixes part of #31201. --- api_docs/changelog.md | 6 +++++ version.py | 2 +- web/src/realm_user_settings_defaults.ts | 1 + web/src/server_events_dispatch.js | 1 + web/src/settings.js | 3 +++ web/src/user_settings.ts | 1 + web/templates/settings/account_settings.hbs | 6 +++++ ...file_allow_private_data_export_and_more.py | 22 +++++++++++++++++ zerver/models/users.py | 2 ++ zerver/openapi/zulip.yaml | 24 +++++++++++++++++++ zerver/tests/test_realm.py | 7 +++++- zerver/views/user_settings.py | 1 + 12 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 zerver/migrations/0585_userprofile_allow_private_data_export_and_more.py diff --git a/api_docs/changelog.md b/api_docs/changelog.md index dc3a63fc8d..3ea445ff5b 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with. ## Changes in Zulip 10.0 +**Feature level 293** + +* [`POST /register`](/api/register-queue), [`PATCH /settings`](/api/update-settings): + Added a new `allow_private_data_export` setting to allow users to decide + whether to let administrators export their private data. + **Feature level 292** * [`POST /register`](/api/register-queue), [`GET diff --git a/version.py b/version.py index 6d6e82dafb..e03874bcab 100644 --- a/version.py +++ b/version.py @@ -34,7 +34,7 @@ DESKTOP_WARNING_VERSION = "5.9.3" # new level means in api_docs/changelog.md, as well as "**Changes**" # entries in the endpoint's documentation in `zulip.yaml`. -API_FEATURE_LEVEL = 292 # Last bumped for `namedusergroup_creator_date_created`. +API_FEATURE_LEVEL = 293 # Last bumped for `allow_private_data_export` setting. # 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. Bump diff --git a/web/src/realm_user_settings_defaults.ts b/web/src/realm_user_settings_defaults.ts index ffbd4eb313..43d52ee401 100644 --- a/web/src/realm_user_settings_defaults.ts +++ b/web/src/realm_user_settings_defaults.ts @@ -3,6 +3,7 @@ import {z} from "zod"; import type {StateData} from "./state_data"; export const realm_default_settings_schema = z.object({ + allow_private_data_export: z.boolean(), automatically_follow_topics_policy: z.number(), automatically_follow_topics_where_mentioned: z.boolean(), automatically_unmute_topics_in_muted_streams_policy: z.number(), diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js index 7830f57459..8401af01b3 100644 --- a/web/src/server_events_dispatch.js +++ b/web/src/server_events_dispatch.js @@ -717,6 +717,7 @@ export function dispatch_normal_event(event) { "send_read_receipts", "presence_enabled", "email_address_visibility", + "allow_private_data_export", ]; if (privacy_settings.includes(event.property)) { diff --git a/web/src/settings.js b/web/src/settings.js index 9d7e7ac061..b12f1f097c 100644 --- a/web/src/settings.js +++ b/web/src/settings.js @@ -29,6 +29,9 @@ export let settings_label; function setup_settings_label() { settings_label = { // settings_notification + allow_private_data_export: $t({ + defaultMessage: "Let administrators export my private data", + }), presence_enabled: $t({ defaultMessage: "Display my availability to other users", }), diff --git a/web/src/user_settings.ts b/web/src/user_settings.ts index 446856afc1..c4293c8cfc 100644 --- a/web/src/user_settings.ts +++ b/web/src/user_settings.ts @@ -34,6 +34,7 @@ export const user_settings_schema = stream_notification_settings_schema .merge(pm_notification_settings_schema) .merge(followed_topic_notification_settings_schema) .extend({ + allow_private_data_export: z.boolean(), automatically_follow_topics_policy: z.number(), automatically_follow_topics_where_mentioned: z.boolean(), automatically_unmute_topics_in_muted_streams_policy: z.number(), diff --git a/web/templates/settings/account_settings.hbs b/web/templates/settings/account_settings.hbs index 1930b59a78..05887aaa4f 100644 --- a/web/templates/settings/account_settings.hbs +++ b/web/templates/settings/account_settings.hbs @@ -94,6 +94,12 @@ label_parens_text=settings_label.presence_enabled_parens_text help_link="/help/status-and-availability" prefix="user_"}} + {{> settings_checkbox + setting_name="allow_private_data_export" + is_checked=settings_object.allow_private_data_export + label=settings_label.allow_private_data_export + help_link="/help/export-your-organization#full-export-with-member-consent" + }}