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.

settings: Add 'allow_private_data_export' user setting.

Prakhar Pratyush764083d31b99
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index dc3a63fc8d9..3ea445ff5b8 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 6d6e82dafba..e03874bcab0 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 ffbd4eb3135..43d52ee4016 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 7830f574590..8401af01b3e 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 9d7e7ac0615..b12f1f097cf 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 446856afc13..c4293c8cfc4 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 1930b59a788..05887aaa4ff 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"
+ }}
</div>
<div class="input-group">
<label for="email_address_visibility" class="settings-field-label">{{t "Who can access your email address" }}
diff --git a/zerver/migrations/0585_userprofile_allow_private_data_export_and_more.py b/zerver/migrations/0585_userprofile_allow_private_data_export_and_more.py
new file mode 100644
index 00000000000..b1848528bd8
--- /dev/null
+++ b/zerver/migrations/0585_userprofile_allow_private_data_export_and_more.py
@@ -0,0 +1,22 @@
+# Generated by Django 5.0.8 on 2024-09-09 08:57
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("zerver", "0584_namedusergroup_creator_date_created_backfill"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="realmuserdefault",
+ name="allow_private_data_export",
+ field=models.BooleanField(default=False),
+ ),
+ migrations.AddField(
+ model_name="userprofile",
+ name="allow_private_data_export",
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/zerver/models/users.py b/zerver/models/users.py
index eef863d2622..718f960f953 100644
--- a/zerver/models/users.py
+++ b/zerver/models/users.py
@@ -267,6 +267,7 @@ class UserBaseSettings(models.Model):
send_stream_typing_notifications = models.BooleanField(default=True)
send_private_typing_notifications = models.BooleanField(default=True)
send_read_receipts = models.BooleanField(default=True)
+ allow_private_data_export = models.BooleanField(default=False)
# Whether the user wants to see typing notifications.
receives_typing_notifications = models.BooleanField(default=True)
@@ -347,6 +348,7 @@ class UserBaseSettings(models.Model):
send_private_typing_notifications=bool,
send_read_receipts=bool,
send_stream_typing_notifications=bool,
+ allow_private_data_export=bool,
web_mark_read_on_scroll_policy=int,
web_channel_default_view=int,
user_list_style=int,
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 1f45e168b6d..25c123eb409 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -14873,6 +14873,13 @@ paths:
read messages.
**Changes**: New in Zulip 5.0 (feature level 105).
+ allow_private_data_export:
+ type: boolean
+ description: |
+ Whether organization administrators are allowed to
+ export your private data.
+
+ **Changes**: New in Zulip 10.0 (feature level 293).
email_address_visibility:
$ref: "#/components/schemas/EmailAddressVisibility"
web_navigate_to_sent_message:
@@ -17370,6 +17377,13 @@ paths:
read messages.
**Changes**: New in Zulip 5.0 (feature level 105).
+ allow_private_data_export:
+ type: boolean
+ description: |
+ Whether organization administrators are allowed to
+ export your private data.
+
+ **Changes**: New in Zulip 10.0 (feature level 293).
email_address_visibility:
$ref: "#/components/schemas/EmailAddressVisibility"
web_navigate_to_sent_message:
@@ -18672,6 +18686,14 @@ paths:
**Changes**: New in Zulip 5.0 (feature level 105).
type: boolean
example: true
+ allow_private_data_export:
+ description: |
+ Whether organization administrators are allowed to
+ export your private data.
+
+ **Changes**: New in Zulip 10.0 (feature level 293).
+ type: boolean
+ example: true
email_address_visibility:
description: |
The [policy][permission-level] this user has selected for [which other
@@ -18807,6 +18829,8 @@ paths:
contentType: application/json
send_read_receipts:
contentType: application/json
+ allow_private_data_export:
+ contentType: application/json
email_address_visibility:
contentType: application/json
web_navigate_to_sent_message:
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index 7865771a4ac..44223438b81 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -2175,7 +2175,12 @@ class RealmAPITest(ZulipTestCase):
# duplicate code. default_language is currently present in Realm table also and thus
# is updated using '/realm' endpoint, but this will be removed in future and the
# settings in RealmUserDefault table will be used.
- if prop in ["default_language", "enable_login_emails", "enable_marketing_emails"]:
+ if prop in [
+ "default_language",
+ "enable_login_emails",
+ "enable_marketing_emails",
+ "allow_private_data_export",
+ ]:
continue
if prop in ["dense_mode"]:
# Testing this is complicated, see test_update_default_information_density_settings.
diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py
index abc7172da1d..431e4f6bab9 100644
--- a/zerver/views/user_settings.py
+++ b/zerver/views/user_settings.py
@@ -314,6 +314,7 @@ def json_change_settings(
send_private_typing_notifications: Json[bool] | None = None,
send_stream_typing_notifications: Json[bool] | None = None,
send_read_receipts: Json[bool] | None = None,
+ allow_private_data_export: Json[bool] | None = None,
user_list_style: Annotated[
Json[int], check_int_in_validator(UserProfile.USER_LIST_STYLE_CHOICES)
]