streams: Hide fake emails in stream creation form.

We hide fake emails in "People to add" section of
stream creation form and instead show user id
along with specifying that email is hidden.
This commit is contained in:
Sahil Batra
2021-11-11 19:26:40 +05:30
committed by Tim Abbott
parent c578f186b6
commit 16d35f5b4e
5 changed files with 51 additions and 5 deletions

View File

@@ -151,18 +151,21 @@ const steven = {
const alice1 = {
email: "alice1@example.com",
delivery_email: "alice1-delivery@example.com",
user_id: 202,
full_name: "Alice",
};
const bob = {
email: "bob@example.com",
delivery_email: "bob-delivery@example.com",
user_id: 203,
full_name: "Bob van Roberts",
};
const alice2 = {
email: "alice2@example.com",
delivery_email: "alice2-delivery@example.com",
user_id: 204,
full_name: "Alice",
};
@@ -556,15 +559,51 @@ test_people("get_people_for_stream_create", () => {
people.add_active_user(bob);
people.add_active_user(alice2);
assert.equal(people.get_active_human_count(), 4);
page_params.is_admin = true;
page_params.realm_email_address_visibility = admins_only;
const others = people.get_people_for_stream_create();
const expected = [
let others = people.get_people_for_stream_create();
let expected = [
{
email: "alice1-delivery@example.com",
user_id: alice1.user_id,
full_name: "Alice",
checked: false,
disabled: false,
show_email: true,
},
{
email: "alice2-delivery@example.com",
user_id: alice2.user_id,
full_name: "Alice",
checked: false,
disabled: false,
show_email: true,
},
{
email: "bob-delivery@example.com",
user_id: bob.user_id,
full_name: "Bob van Roberts",
checked: false,
disabled: false,
show_email: true,
},
];
assert.deepEqual(others, expected);
page_params.is_admin = false;
alice1.delivery_email = undefined;
alice2.delivery_email = undefined;
bob.delivery_email = undefined;
others = people.get_people_for_stream_create();
expected = [
{
email: "alice1@example.com",
user_id: alice1.user_id,
full_name: "Alice",
checked: false,
disabled: false,
show_email: false,
},
{
email: "alice2@example.com",
@@ -572,6 +611,7 @@ test_people("get_people_for_stream_create", () => {
full_name: "Alice",
checked: false,
disabled: false,
show_email: false,
},
{
email: "bob@example.com",
@@ -579,6 +619,7 @@ test_people("get_people_for_stream_create", () => {
full_name: "Bob van Roberts",
checked: false,
disabled: false,
show_email: false,
},
];
assert.deepEqual(others, expected);

View File

@@ -1069,7 +1069,8 @@ export function get_people_for_stream_create() {
for (const person of active_user_dict.values()) {
if (!is_my_user_id(person.user_id)) {
people_minus_you.push({
email: person.email,
email: get_visible_email(person),
show_email: settings_data.show_email(),
user_id: person.user_id,
full_name: person.full_name,
checked: false,

View File

@@ -13,6 +13,7 @@ import * as loading from "./loading";
import {page_params} from "./page_params";
import * as peer_data from "./peer_data";
import * as people from "./people";
import * as settings_data from "./settings_data";
import * as stream_data from "./stream_data";
import * as stream_settings_data from "./stream_settings_data";
import * as stream_settings_ui from "./stream_settings_ui";
@@ -312,7 +313,8 @@ export function show_new_stream_modal() {
// Add current user on top of list
const current_user = people.get_by_user_id(page_params.user_id);
all_users.unshift({
email: current_user.email,
show_email: settings_data.show_email(),
email: people.get_visible_email(current_user),
user_id: current_user.user_id,
full_name: current_user.full_name,
checked: true,

View File

@@ -1,5 +1,5 @@
<label class="checkbox add-user-label" id="user_checkbox_{{user_id}}">
<input type="checkbox" name="user" {{#if checked}}checked="checked"{{#if disabled}} disabled="disabled"{{/if}}{{/if}} data-user-id="{{user_id}}"/>
<span></span>
{{full_name}} ({{email}})
{{full_name}} {{#if show_email}}({{email}}){{else}}({{#tr}}User ID: {user_id}; <em>email hidden</em>{{/tr}}){{/if}}
</label>

View File

@@ -165,6 +165,8 @@ IGNORED_PHRASES = [
# Used in our case studies
r"Technical University of Munich",
r"University of California San Diego",
# Used in stream creation form
r"email hidden",
]
# Sort regexes in descending order of their lengths. As a result, the