mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
This extends our email address visibility settings to deny access to user email addresses even to organization administrators. At the moment, they can of course change the setting (which leaves an audit trail), but in the future only organization owners will be able to change that setting. While we're at this, we rewrite the settings_data.js test to cover all the cases in a more consistent way. Fixes #14111.
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
const settings_config = require("./settings_config");
|
|
|
|
/*
|
|
This is a close cousin of settings_config,
|
|
but this has a bit more logic, and we
|
|
ensure 100% line coverage on it.
|
|
|
|
Our main goal with this code is to isolate
|
|
some key modules from having to know
|
|
about page_params and settings_config details.
|
|
*/
|
|
|
|
exports.show_email = function () {
|
|
if (page_params.realm_email_address_visibility ===
|
|
settings_config.email_address_visibility_values.everyone.code) {
|
|
return true;
|
|
}
|
|
if (page_params.realm_email_address_visibility ===
|
|
settings_config.email_address_visibility_values.admins_only.code) {
|
|
return page_params.is_admin;
|
|
}
|
|
};
|
|
|
|
exports.email_for_user_settings = function (person) {
|
|
if (!exports.show_email()) {
|
|
return;
|
|
}
|
|
|
|
if (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.email;
|
|
};
|
|
|
|
exports.get_time_preferences = function (user_timezone) {
|
|
if (page_params.twenty_four_hour_time) {
|
|
return {
|
|
timezone: user_timezone,
|
|
format: "H:mm",
|
|
};
|
|
}
|
|
return {
|
|
timezone: user_timezone,
|
|
format: "h:mm A",
|
|
};
|
|
};
|