mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 19:43:47 +00:00
compose_validate: Remove invalid email messaging.
This should no longer be possible because we validate emails before creating user pills.
This commit is contained in:
@@ -88,15 +88,11 @@ export function get_user_ids_string(): string {
|
||||
return user_ids_string;
|
||||
}
|
||||
|
||||
export let get_emails = (): string => {
|
||||
export function get_emails(): string {
|
||||
// return something like "alice@example.com,bob@example.com"
|
||||
const user_ids = get_user_ids();
|
||||
const emails = user_ids.map((id) => people.get_by_user_id(id).email).join(",");
|
||||
return emails;
|
||||
};
|
||||
|
||||
export function rewire_get_emails(value: typeof get_emails): void {
|
||||
get_emails = value;
|
||||
}
|
||||
|
||||
export function filter_taken_users(persons: User[]): User[] {
|
||||
|
||||
@@ -652,17 +652,6 @@ export function set_user_acknowledged_stream_wildcard_flag(value: boolean): void
|
||||
user_acknowledged_stream_wildcard = value;
|
||||
}
|
||||
|
||||
export function get_invalid_recipient_emails(): string[] {
|
||||
const private_recipients = util.extract_pm_recipients(
|
||||
compose_state.private_message_recipient(),
|
||||
);
|
||||
const invalid_recipients = private_recipients.filter(
|
||||
(email) => !people.is_valid_email_for_compose(email),
|
||||
);
|
||||
|
||||
return invalid_recipients;
|
||||
}
|
||||
|
||||
function is_recipient_large_stream(): boolean {
|
||||
const stream_id = compose_state.stream_id();
|
||||
if (stream_id === undefined) {
|
||||
@@ -915,42 +904,7 @@ function validate_private_message(show_banner = true): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
const invalid_recipients = get_invalid_recipient_emails();
|
||||
|
||||
let context = {};
|
||||
if (invalid_recipients.length === 1) {
|
||||
context = {recipient: invalid_recipients.join(",")};
|
||||
const error_message = $t(
|
||||
{defaultMessage: "The recipient {recipient} is not valid."},
|
||||
context,
|
||||
);
|
||||
compose_banner.show_error_message(
|
||||
error_message,
|
||||
compose_banner.CLASSNAMES.invalid_recipient,
|
||||
$banner_container,
|
||||
$("#private_message_recipient"),
|
||||
);
|
||||
if (is_validating_compose_box) {
|
||||
disabled_send_tooltip_message = error_message;
|
||||
}
|
||||
return false;
|
||||
} else if (invalid_recipients.length > 1) {
|
||||
context = {recipients: invalid_recipients.join(",")};
|
||||
const error_message = $t(
|
||||
{defaultMessage: "The recipients {recipients} are not valid."},
|
||||
context,
|
||||
);
|
||||
compose_banner.show_error_message(
|
||||
error_message,
|
||||
compose_banner.CLASSNAMES.invalid_recipients,
|
||||
$banner_container,
|
||||
$("#private_message_recipient"),
|
||||
);
|
||||
if (is_validating_compose_box) {
|
||||
disabled_send_tooltip_message = error_message;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const user_id of user_ids) {
|
||||
if (!people.is_person_active(user_id)) {
|
||||
|
||||
@@ -362,26 +362,6 @@ test_ui("validate", ({mock_template, override}) => {
|
||||
}
|
||||
});
|
||||
|
||||
test_ui("get_invalid_recipient_emails", ({override, override_rewire}) => {
|
||||
const welcome_bot = {
|
||||
email: "welcome-bot@example.com",
|
||||
user_id: 124,
|
||||
full_name: "Welcome Bot",
|
||||
};
|
||||
|
||||
override(current_user, "user_id", me.user_id);
|
||||
|
||||
const params = {};
|
||||
params.realm_users = [];
|
||||
params.realm_non_active_users = [];
|
||||
params.cross_realm_bots = [welcome_bot];
|
||||
|
||||
people.initialize(current_user.user_id, params);
|
||||
|
||||
override_rewire(compose_pm_pill, "get_emails", () => "welcome-bot@example.com");
|
||||
assert.deepEqual(compose_validate.get_invalid_recipient_emails(), []);
|
||||
});
|
||||
|
||||
test_ui("test_stream_wildcard_mention_allowed", ({override, override_rewire}) => {
|
||||
override(current_user, "user_id", me.user_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user