mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
setting: Add moderator option in email visibility setting in frontend.
This commit is contained in:
@@ -45,6 +45,17 @@ run_test("email_for_user_settings", () => {
|
|||||||
page_params.realm_email_address_visibility =
|
page_params.realm_email_address_visibility =
|
||||||
settings_config.email_address_visibility_values.everyone.code;
|
settings_config.email_address_visibility_values.everyone.code;
|
||||||
assert.equal(email(isaac), isaac.email);
|
assert.equal(email(isaac), isaac.email);
|
||||||
|
|
||||||
|
page_params.realm_email_address_visibility =
|
||||||
|
settings_config.email_address_visibility_values.moderators.code;
|
||||||
|
assert.equal(email(isaac), undefined);
|
||||||
|
|
||||||
|
page_params.is_moderator = true;
|
||||||
|
assert.equal(email(isaac), isaac.delivery_email);
|
||||||
|
|
||||||
|
page_params.is_moderator = false;
|
||||||
|
page_params.is_admin = true;
|
||||||
|
assert.equal(email(isaac), isaac.delivery_email);
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("user_can_change_name", () => {
|
run_test("user_can_change_name", () => {
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ export const email_address_visibility_values = {
|
|||||||
// code: 2,
|
// code: 2,
|
||||||
// description: $t({defaultMessage: "Members and admins"}),
|
// description: $t({defaultMessage: "Members and admins"}),
|
||||||
// },
|
// },
|
||||||
|
moderators: {
|
||||||
|
code: 5,
|
||||||
|
description: $t({defaultMessage: "Admins and moderators"}),
|
||||||
|
},
|
||||||
admins_only: {
|
admins_only: {
|
||||||
code: 3,
|
code: 3,
|
||||||
description: $t({defaultMessage: "Admins only"}),
|
description: $t({defaultMessage: "Admins only"}),
|
||||||
|
|||||||
@@ -12,6 +12,29 @@ import * as settings_config from "./settings_config";
|
|||||||
about page_params and settings_config details.
|
about page_params and settings_config details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function user_can_access_delivery_email() {
|
||||||
|
// This function checks whether the current user should expect to
|
||||||
|
// see .delivery_email fields on user objects that it can access.
|
||||||
|
//
|
||||||
|
// If false, either everyone has access to emails (and there is no
|
||||||
|
// delivery_email field for anyone) or this user does not have
|
||||||
|
// access to emails (and this client will never receive a user
|
||||||
|
// object with a delivery_email field).
|
||||||
|
if (
|
||||||
|
page_params.realm_email_address_visibility ===
|
||||||
|
settings_config.email_address_visibility_values.admins_only.code
|
||||||
|
) {
|
||||||
|
return page_params.is_admin;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
page_params.realm_email_address_visibility ===
|
||||||
|
settings_config.email_address_visibility_values.moderators.code
|
||||||
|
) {
|
||||||
|
return page_params.is_admin || page_params.is_moderator;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
export function show_email() {
|
export function show_email() {
|
||||||
if (
|
if (
|
||||||
page_params.realm_email_address_visibility ===
|
page_params.realm_email_address_visibility ===
|
||||||
@@ -19,13 +42,7 @@ export function show_email() {
|
|||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (
|
return user_can_access_delivery_email();
|
||||||
page_params.realm_email_address_visibility ===
|
|
||||||
settings_config.email_address_visibility_values.admins_only.code
|
|
||||||
) {
|
|
||||||
return page_params.is_admin;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function email_for_user_settings(person) {
|
export function email_for_user_settings(person) {
|
||||||
@@ -33,12 +50,7 @@ export function email_for_user_settings(person) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (person.delivery_email && user_can_access_delivery_email()) {
|
||||||
page_params.is_admin &&
|
|
||||||
person.delivery_email &&
|
|
||||||
page_params.realm_email_address_visibility ===
|
|
||||||
settings_config.email_address_visibility_values.admins_only.code
|
|
||||||
) {
|
|
||||||
return person.delivery_email;
|
return person.delivery_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user