settings: Remove realm-level email_address_visibility setting.

This was replaced by the new user-level version in recent commits.

Fixes #20035.
Fixes #18149.
This commit is contained in:
Sahil Batra 2021-10-28 00:09:45 +05:30 committed by Tim Abbott
parent 1b110552ec
commit 9d1dc20e6e
24 changed files with 32 additions and 162 deletions

View File

@ -37,6 +37,8 @@ format used by the Zulip server that they are interacting with.
/realm/user_settings_defaults`](/api/update-realm-user-settings-defaults): Added
user setting `email_address_visibility` which will replace the existing realm
setting `email_address_visibility`.
* [`POST /register`](/api/register-queue), [`PATCH /realm`]: Removed realm-level
`email_address_visibility` setting.
**Feature level 162**

View File

@ -477,10 +477,6 @@ run_test("realm settings", ({override}) => {
event = event_fixtures.realm__update__disallow_disposable_email_addresses;
test_realm_boolean(event, "realm_disallow_disposable_email_addresses");
event = event_fixtures.realm__update__email_addresses_visibility;
dispatch(event);
assert_same(page_params.realm_email_address_visibility, 3);
event = event_fixtures.realm__update__notifications_stream_id;
dispatch(event);
assert_same(page_params.realm_notifications_stream_id, 42);

View File

@ -296,13 +296,6 @@ exports.fixtures = {
value: false,
},
realm__update__email_addresses_visibility: {
type: "realm",
op: "update",
property: "email_address_visibility",
value: 3,
},
realm__update__emails_restricted_to_domains: {
type: "realm",
op: "update",

View File

@ -16,13 +16,6 @@ const message_user_ids = mock_esm("../../static/js/message_user_ids");
const muted_users = zrequire("muted_users");
const people = zrequire("people");
const settings_config = zrequire("settings_config");
const visibility = settings_config.email_address_visibility_values;
const admins_only = visibility.admins_only.code;
function set_email_visibility(code) {
page_params.realm_email_address_visibility = code;
}
const welcome_bot = {
email: "welcome-bot@example.com",
@ -56,7 +49,6 @@ function initialize() {
people.init();
people.add_active_user({...me});
people.initialize_current_user(me.user_id);
set_email_visibility(admins_only);
muted_users.set_muted_users([]);
}

View File

@ -101,7 +101,6 @@ function make_image_stubber() {
function test_ui(label, f) {
run_test(label, (handlers) => {
page_params.is_admin = false;
page_params.realm_email_address_visibility = 3;
page_params.custom_profile_fields = [];
popovers.clear_for_testing();
popovers.register_click_handlers();

View File

@ -9,8 +9,6 @@ const {page_params} = require("../zjsunit/zpage_params");
const narrow_state = mock_esm("../../static/js/narrow_state");
const stream_topic_history_util = mock_esm("../../static/js/stream_topic_history_util");
const settings_config = zrequire("settings_config");
const huddle_data = zrequire("huddle_data");
const stream_data = zrequire("stream_data");
@ -57,8 +55,6 @@ const example_avatar_url = "http://example.com/example.png";
function init() {
page_params.is_admin = true;
page_params.search_pills_enabled = true;
page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code;
people.init();
people.add_active_user(bob);

View File

@ -9,8 +9,6 @@ const {page_params} = require("../zjsunit/zpage_params");
const narrow_state = mock_esm("../../static/js/narrow_state");
const stream_topic_history_util = mock_esm("../../static/js/stream_topic_history_util");
const settings_config = zrequire("settings_config");
const huddle_data = zrequire("huddle_data");
const stream_data = zrequire("stream_data");
@ -56,8 +54,6 @@ const example_avatar_url = "http://example.com/example.png";
function init() {
page_params.is_admin = true;
page_params.search_pills_enabled = false;
page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code;
people.init();
people.add_active_user(bob);

View File

@ -99,8 +99,6 @@ function createSaveButtons(subsection) {
function test_submit_settings_form(override, submit_form) {
Object.assign(page_params, {
realm_bot_creation_policy: settings_bots.bot_creation_policy_values.restricted.code,
realm_email_address_visibility:
settings_config.email_address_visibility_values.admins_only.code,
realm_add_custom_emoji_policy: settings_config.common_policy_values.by_admins_only.code,
realm_waiting_period_threshold: 1,
realm_default_language: '"es"',
@ -159,10 +157,6 @@ function test_submit_settings_form(override, submit_form) {
$bot_creation_policy_elem.val("1");
$bot_creation_policy_elem.attr("id", "id_realm_bot_creation_policy");
$bot_creation_policy_elem.data = () => "number";
const $email_address_visibility_elem = $("#id_realm_email_address_visibility");
$email_address_visibility_elem.val("1");
$email_address_visibility_elem.attr("id", "id_realm_email_address_visibility");
$email_address_visibility_elem.data = () => "number";
const $invite_to_realm_policy_elem = $("#id_realm_invite_to_realm_policy");
$invite_to_realm_policy_elem.val("2");
@ -172,7 +166,6 @@ function test_submit_settings_form(override, submit_form) {
let $subsection_elem = $(`#org-${CSS.escape(subsection)}`);
$subsection_elem.set_find_results(".prop-element", [
$bot_creation_policy_elem,
$email_address_visibility_elem,
$add_custom_emoji_policy_elem,
$create_public_stream_policy_elem,
$create_private_stream_policy_elem,
@ -188,7 +181,6 @@ function test_submit_settings_form(override, submit_form) {
bot_creation_policy: 1,
invite_to_realm_policy: 2,
invite_to_stream_policy: 1,
email_address_visibility: 1,
add_custom_emoji_policy: 1,
create_public_stream_policy: 2,
create_private_stream_policy: 2,

View File

@ -106,8 +106,6 @@ function test(label, f) {
people.clear_recipient_counts_for_testing();
page_params.is_admin = false;
page_params.realm_is_zephyr_mirror_realm = false;
page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code;
f(helpers);
});

View File

@ -223,7 +223,6 @@ export function build_page() {
insert_tip_box();
$("#id_realm_bot_creation_policy").val(page_params.realm_bot_creation_policy);
$("#id_realm_email_address_visibility").val(page_params.realm_email_address_visibility);
$("#id_realm_digest_weekday").val(options.realm_digest_weekday);
}

View File

@ -21,7 +21,6 @@ export const page_params: {
realm_create_web_public_stream_policy: number;
realm_delete_own_message_policy: number;
realm_edit_topic_policy: number;
realm_email_address_visibility: number;
realm_email_changes_disabled: boolean;
realm_enable_spectator_access: boolean;
realm_invite_to_realm_policy: number;

View File

@ -202,7 +202,6 @@ export function dispatch_normal_event(event) {
description: noop,
digest_emails_enabled: noop,
digest_weekday: noop,
email_address_visibility: noop,
email_changes_disabled: settings_account.update_email_change_display,
disallow_disposable_email_addresses: noop,
inline_image_preview: noop,

View File

@ -1474,7 +1474,6 @@ $option_title_width: 180px;
#id_realm_private_message_policy,
#id_realm_add_custom_emoji_policy,
#id_realm_user_group_edit_policy,
#id_realm_email_address_visibility,
#id_realm_wildcard_mention_policy,
#id_realm_move_messages_between_streams_policy,
#id_realm_invite_to_realm_policy,

View File

@ -81,14 +81,6 @@
is_checked=realm_avatar_changes_disabled
label=admin_settings_label.realm_avatar_changes_disabled}}
</div>
<div class="input-group">
<label for="realm_email_address_visibility">{{t "Who can access user email addresses" }}
{{> ../help_link_widget link="/help/restrict-visibility-of-email-addresses" }}
</label>
<select name="realm_email_address_visibility" class="setting-widget prop-element bootstrap-focus-style" id="id_realm_email_address_visibility" data-setting-widget-type="number">
{{> dropdown_options_widget option_values=email_address_visibility_values}}
</select>
</div>
</div>
<div id="org-stream-permissions" class="settings-subsection-parent">

View File

@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
# Changes should be accompanied by documentation explaining what the
# new level means in api_docs/changelog.md, as well as "**Changes**"
# entries in the endpoint's documentation in `zulip.yaml`.
API_FEATURE_LEVEL = 162
API_FEATURE_LEVEL = 163
# 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

View File

@ -12,13 +12,7 @@ from confirmation.models import Confirmation, create_confirmation_link, generate
from zerver.actions.custom_profile_fields import do_remove_realm_custom_profile_fields
from zerver.actions.message_delete import do_delete_messages_by_sender
from zerver.actions.user_groups import update_users_in_full_members_system_group
from zerver.actions.user_settings import (
do_delete_avatar_image,
send_delivery_email_update_events,
send_user_email_update_event,
)
from zerver.lib.cache import flush_user_profile
from zerver.lib.create_user import get_display_email_address
from zerver.actions.user_settings import do_delete_avatar_image
from zerver.lib.message import parse_message_time_limit_setting, update_first_visible_message_id
from zerver.lib.send_email import FromAddress, send_email_to_admins
from zerver.lib.sessions import delete_user_sessions
@ -98,30 +92,6 @@ def do_set_realm_property(
).decode(),
)
if name == "email_address_visibility":
user_profiles = UserProfile.objects.filter(realm=realm, is_bot=False)
for user_profile in user_profiles:
send_delivery_email_update_events(user_profile, old_value, value)
if Realm.EMAIL_ADDRESS_VISIBILITY_EVERYONE not in [old_value, value]:
# We use real email addresses on UserProfile.email only if
# EMAIL_ADDRESS_VISIBILITY_EVERYONE is configured, so
# changes between values that will not require changing
# that field, so we can save work and return here.
return
for user_profile in user_profiles:
user_profile.email = get_display_email_address(user_profile)
UserProfile.objects.bulk_update(user_profiles, ["email"])
for user_profile in user_profiles:
transaction.on_commit(
lambda: flush_user_profile(sender=UserProfile, instance=user_profile)
)
# TODO: Design a bulk event for this or force-reload all clients
send_user_email_update_event(user_profile)
if name == "waiting_period_threshold":
update_users_in_full_members_system_group(realm, acting_user=acting_user)

View File

@ -0,0 +1,16 @@
# Generated by Django 3.2.8 on 2021-10-28 14:53
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("zerver", "0427_migrate_to_user_level_email_address_visibility_setting"),
]
operations = [
migrations.RemoveField(
model_name="realm",
name="email_address_visibility",
),
]

View File

@ -449,26 +449,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
WILDCARD_MENTION_POLICY_MODERATORS,
]
# Who in the organization has access to users' actual email
# addresses. Controls whether the UserProfile.email field is the
# same as UserProfile.delivery_email, or is instead garbage.
EMAIL_ADDRESS_VISIBILITY_EVERYONE = 1
EMAIL_ADDRESS_VISIBILITY_MEMBERS = 2
EMAIL_ADDRESS_VISIBILITY_ADMINS = 3
EMAIL_ADDRESS_VISIBILITY_NOBODY = 4
EMAIL_ADDRESS_VISIBILITY_MODERATORS = 5
email_address_visibility = models.PositiveSmallIntegerField(
default=EMAIL_ADDRESS_VISIBILITY_EVERYONE,
)
EMAIL_ADDRESS_VISIBILITY_TYPES = [
EMAIL_ADDRESS_VISIBILITY_EVERYONE,
# The MEMBERS level is not yet implemented on the backend.
## EMAIL_ADDRESS_VISIBILITY_MEMBERS,
EMAIL_ADDRESS_VISIBILITY_ADMINS,
EMAIL_ADDRESS_VISIBILITY_NOBODY,
EMAIL_ADDRESS_VISIBILITY_MODERATORS,
]
# Threshold in days for new users to create streams, and potentially take
# some other actions.
waiting_period_threshold = models.PositiveIntegerField(default=0)
@ -725,7 +705,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
digest_weekday=int,
disallow_disposable_email_addresses=bool,
edit_topic_policy=int,
email_address_visibility=int,
email_changes_disabled=bool,
emails_restricted_to_domains=bool,
enable_read_receipts=bool,

View File

@ -3772,6 +3772,12 @@ paths:
Unlike the simpler [realm/update](#realm-update) event format, this
event type supports multiple properties being changed in a
single event.
**Changes**: The `email_address_visibility` setting was removed in Zulip 7.0 (feature level 163).
It was replaced by a [user setting](/api/update-settings) with a
[realm user default](/api/update-realm-user-settings-defaults), with the encoding of different
values preserved. Clients can support all versions by supporting the current API and treating
every user as having the realm's email address visibility value.
properties:
id:
$ref: "#/components/schemas/EventIdSchema"
@ -3912,21 +3918,6 @@ paths:
[permission-level]: /api/roles-and-permissions#permission-levels
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
email_address_visibility:
type: integer
description: |
The [policy][permission-level] for which users in this organization can see
the real email addresses of other users.
- 1 = Everyone
- 2 = Members only
- 3 = Administrators only
- 4 = Nobody (though note that administrators can change this setting)
- 5 = Moderators only
**Changes**: Nobody added as an option in Zulip 3.0 (feature level 1).
[permission-level]: /api/roles-and-permissions#permission-levels
email_changes_disabled:
type: boolean
description: |
@ -9911,6 +9902,12 @@ paths:
if you need deeper details about how the Zulip event queue system
works, avoids clients needing to worry about large classes of
potentially messy races, etc.
**Changes**: The `email_address_visibility` setting was removed in Zulip 7.0 (feature level 163).
It was replaced by a [user setting](/api/update-settings) with a
[realm user default](/api/update-realm-user-settings-defaults), with the encoding of different
values preserved. Clients can support all versions by supporting the current API and treating
every user as having the realm's email address visibility value.
x-curl-examples-parameters:
oneOf:
- type: include
@ -11956,23 +11953,6 @@ paths:
Whether the organization disallows disposable email
addresses.
realm_email_address_visibility:
type: integer
description: |
Present if `realm` is present in `fetch_event_types`.
The [policy][permission-level] for which users in this organization can see
the real email addresses of other users.
- 1 = Everyone
- 2 = Members only
- 3 = Administrators only
- 4 = Nobody (though note that administrators can change this setting)
- 5 = Moderators only
**Changes**: Nobody added as an option in Zulip 3.0 (feature level 1).
[permission-level]: /api/roles-and-permissions#permission-levels
realm_email_changes_disabled:
type: boolean
description: |

View File

@ -2602,7 +2602,6 @@ class RealmPropertyActionTest(BaseAction):
private_message_policy=Realm.PRIVATE_MESSAGE_POLICY_TYPES,
user_group_edit_policy=Realm.COMMON_POLICY_TYPES,
wildcard_mention_policy=Realm.WILDCARD_MENTION_POLICY_TYPES,
email_address_visibility=Realm.EMAIL_ADDRESS_VISIBILITY_TYPES,
bot_creation_policy=Realm.BOT_CREATION_POLICY_TYPES,
video_chat_provider=[
Realm.VIDEO_CHAT_PROVIDERS["jitsi_meet"]["id"],
@ -2645,15 +2644,6 @@ class RealmPropertyActionTest(BaseAction):
state_change_expected = True
old_value = vals[count]
num_events = 1
if name == "email_address_visibility" and Realm.EMAIL_ADDRESS_VISIBILITY_EVERYONE in [
old_value,
val,
]:
# one event for updating "email_address_visibility" setting +
# one delivery_email update event is sent for 9 users (all human
# users except the user themselves) + one email update event for
# each of the 10 human users in the realm.
num_events = 20
events = self.verify_action(
lambda: do_set_realm_property(
@ -2689,13 +2679,6 @@ class RealmPropertyActionTest(BaseAction):
else:
check_realm_update("events[0]", events[0], name)
if name == "email_address_visibility" and Realm.EMAIL_ADDRESS_VISIBILITY_EVERYONE in [
old_value,
val,
]:
check_realm_user_update("events[1]", events[1], "delivery_email")
check_realm_user_update("events[10]", events[10], "email")
def test_change_realm_property(self) -> None:
for prop in Realm.property_types:
with self.settings(SEND_DIGEST_EMAILS=True):

View File

@ -132,7 +132,6 @@ class HomeTest(ZulipTestCase):
"realm_disallow_disposable_email_addresses",
"realm_domains",
"realm_edit_topic_policy",
"realm_email_address_visibility",
"realm_email_auth_enabled",
"realm_email_changes_disabled",
"realm_emails_restricted_to_domains",

View File

@ -623,7 +623,6 @@ class RealmTest(ZulipTestCase):
create_private_stream_policy=10,
create_web_public_stream_policy=10,
invite_to_stream_policy=10,
email_address_visibility=10,
message_retention_days=10,
video_chat_provider=10,
giphy_rating=10,
@ -865,7 +864,6 @@ class RealmTest(ZulipTestCase):
self.assertEqual(realm.string_id, "realm_string_id")
self.assertEqual(realm.name, "realm name")
self.assertFalse(realm.emails_restricted_to_domains)
self.assertEqual(realm.email_address_visibility, Realm.EMAIL_ADDRESS_VISIBILITY_EVERYONE)
self.assertEqual(realm.description, "")
self.assertTrue(realm.invite_required)
self.assertEqual(realm.plan_type, Realm.PLAN_TYPE_LIMITED)
@ -895,7 +893,6 @@ class RealmTest(ZulipTestCase):
"realm name",
emails_restricted_to_domains=True,
date_created=date_created,
email_address_visibility=Realm.EMAIL_ADDRESS_VISIBILITY_MEMBERS,
description="realm description",
invite_required=False,
plan_type=Realm.PLAN_TYPE_STANDARD_FREE,
@ -904,7 +901,6 @@ class RealmTest(ZulipTestCase):
self.assertEqual(realm.string_id, "realm_string_id")
self.assertEqual(realm.name, "realm name")
self.assertTrue(realm.emails_restricted_to_domains)
self.assertEqual(realm.email_address_visibility, Realm.EMAIL_ADDRESS_VISIBILITY_MEMBERS)
self.assertEqual(realm.description, "realm description")
self.assertFalse(realm.invite_required)
self.assertEqual(realm.plan_type, Realm.PLAN_TYPE_STANDARD_FREE)
@ -1159,7 +1155,6 @@ class RealmAPITest(ZulipTestCase):
invite_to_stream_policy=Realm.COMMON_POLICY_TYPES,
wildcard_mention_policy=Realm.WILDCARD_MENTION_POLICY_TYPES,
bot_creation_policy=Realm.BOT_CREATION_POLICY_TYPES,
email_address_visibility=Realm.EMAIL_ADDRESS_VISIBILITY_TYPES,
video_chat_provider=[
dict(
video_chat_provider=orjson.dumps(

View File

@ -127,9 +127,6 @@ def update_realm(
wildcard_mention_policy: Optional[int] = REQ(
json_validator=check_int_in(Realm.WILDCARD_MENTION_POLICY_TYPES), default=None
),
email_address_visibility: Optional[int] = REQ(
json_validator=check_int_in(Realm.EMAIL_ADDRESS_VISIBILITY_TYPES), default=None
),
video_chat_provider: Optional[int] = REQ(json_validator=check_int, default=None),
giphy_rating: Optional[int] = REQ(json_validator=check_int, default=None),
default_code_block_language: Optional[str] = REQ(default=None),

View File

@ -316,7 +316,6 @@ class Command(BaseCommand):
string_id="zulip",
name="Zulip Dev",
emails_restricted_to_domains=False,
email_address_visibility=Realm.EMAIL_ADDRESS_VISIBILITY_ADMINS,
description="The Zulip development environment default organization."
" It's great for testing!",
invite_required=False,