mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
people: Extract emails_to_full_names_string helper.
This code that previously lived in a larger function is needed by another function in PR #22127.
This commit is contained in:
@@ -664,6 +664,24 @@ test_people("multi_user_methods", () => {
|
|||||||
assert.equal(people.reply_to_to_user_ids_string("invalid@example.com"), undefined);
|
assert.equal(people.reply_to_to_user_ids_string("invalid@example.com"), undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test_people("emails_to_full_names_string", () => {
|
||||||
|
people.add_active_user(charles);
|
||||||
|
people.add_active_user(maria);
|
||||||
|
assert.equal(
|
||||||
|
people.emails_to_full_names_string([charles.email, maria.email]),
|
||||||
|
`${charles.full_name}, ${maria.full_name}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
people.emails_to_full_names_string([
|
||||||
|
charles.email,
|
||||||
|
"unknown-email@example.com",
|
||||||
|
maria.email,
|
||||||
|
]),
|
||||||
|
`${charles.full_name}, unknown-email@example.com, ${maria.full_name}`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test_people("concat_huddle", () => {
|
test_people("concat_huddle", () => {
|
||||||
/*
|
/*
|
||||||
We assume that user_ids passed in
|
We assume that user_ids passed in
|
||||||
|
|||||||
@@ -324,16 +324,7 @@ export function format_draft(draft) {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const emails = util.extract_pm_recipients(draft.private_message_recipient);
|
const emails = util.extract_pm_recipients(draft.private_message_recipient);
|
||||||
const recipients = emails
|
const recipients = people.emails_to_full_names_string(emails);
|
||||||
.map((email) => {
|
|
||||||
email = email.trim();
|
|
||||||
const person = people.get_by_email(email);
|
|
||||||
if (person !== undefined) {
|
|
||||||
return person.full_name;
|
|
||||||
}
|
|
||||||
return email;
|
|
||||||
})
|
|
||||||
.join(", ");
|
|
||||||
|
|
||||||
formatted = {
|
formatted = {
|
||||||
draft_id: draft.id,
|
draft_id: draft.id,
|
||||||
|
|||||||
@@ -256,6 +256,19 @@ export function reply_to_to_user_ids_string(emails_string) {
|
|||||||
return user_ids.join(",");
|
return user_ids.join(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function emails_to_full_names_string(emails) {
|
||||||
|
return emails
|
||||||
|
.map((email) => {
|
||||||
|
email = email.trim();
|
||||||
|
const person = get_by_email(email);
|
||||||
|
if (person !== undefined) {
|
||||||
|
return person.full_name;
|
||||||
|
}
|
||||||
|
return email;
|
||||||
|
})
|
||||||
|
.join(", ");
|
||||||
|
}
|
||||||
|
|
||||||
export function get_user_time_preferences(user_id) {
|
export function get_user_time_preferences(user_id) {
|
||||||
const user_timezone = get_by_user_id(user_id).timezone;
|
const user_timezone = get_by_user_id(user_id).timezone;
|
||||||
if (user_timezone) {
|
if (user_timezone) {
|
||||||
|
|||||||
Reference in New Issue
Block a user