echo: Remove support for zephyr mirroring.

This commit is contained in:
Varun Singh
2024-07-16 23:31:26 +05:30
committed by Tim Abbott
parent 3d01ccbbd5
commit 126d4fb137
5 changed files with 5 additions and 66 deletions

View File

@@ -120,24 +120,6 @@ export function build_display_recipient(message) {
const display_recipient = emails.map((email) => { const display_recipient = emails.map((email) => {
email = email.trim(); email = email.trim();
const person = people.get_by_email(email); const person = people.get_by_email(email);
if (person === undefined) {
// For unknown users, we return a skeleton object.
//
// This allows us to support zephyr mirroring situations
// where the server might dynamically create users in
// response to messages being sent to their email address.
//
// TODO: It might be cleaner for the web app for such
// dynamic user creation to happen inside a separate API
// call when the pill is constructed, and then enforcing
// the requirement that we have an actual user object in
// `people.js` when sending messages.
return {
email,
full_name: email,
unknown_local_echo_user: true,
};
}
if (person.user_id === message.sender_id) { if (person.user_id === message.sender_id) {
sender_in_display_recipients = true; sender_in_display_recipients = true;

View File

@@ -20,7 +20,6 @@ export type DisplayRecipientUser = {
full_name: string; full_name: string;
id: number; id: number;
is_mirror_dummy: boolean; is_mirror_dummy: boolean;
unknown_local_echo_user?: boolean;
}; };
export type DisplayRecipient = string | DisplayRecipientUser[]; export type DisplayRecipient = string | DisplayRecipientUser[];

View File

@@ -1526,10 +1526,6 @@ export function extract_people_from_message(message: MessageWithBooleans): void
// Add new people involved in this message to the people list // Add new people involved in this message to the people list
for (const person of involved_people) { for (const person of involved_people) {
if (person.unknown_local_echo_user) {
continue;
}
const user_id = person.id; const user_id = person.id;
if (people_by_user_id_dict.has(user_id)) { if (people_by_user_id_dict.has(user_id)) {
@@ -1605,10 +1601,6 @@ export function maybe_incr_recipient_count(
// Track the number of direct messages we've sent to this person // Track the number of direct messages we've sent to this person
// to improve autocomplete // to improve autocomplete
for (const recip of message.display_recipient) { for (const recip of message.display_recipient) {
if (recip.unknown_local_echo_user) {
continue;
}
const user_id = recip.id; const user_id = recip.id;
incr_recipient_count(user_id); incr_recipient_count(user_id);
} }

View File

@@ -217,13 +217,13 @@ run_test("build_display_recipient", () => {
message = { message = {
type: "private", type: "private",
private_message_recipient: "cordelia@zulip.com,hamlet@zulip.com", private_message_recipient: "cordelia@zulip.com",
sender_email: "iago@zulip.com", sender_email: "iago@zulip.com",
sender_full_name: "Iago", sender_full_name: "Iago",
sender_id: 123, sender_id: 123,
}; };
display_recipient = echo.build_display_recipient(message); display_recipient = echo.build_display_recipient(message);
assert.equal(display_recipient.length, 3); assert.equal(display_recipient.length, 2);
let iago = display_recipient.find((recipient) => recipient.email === "iago@zulip.com"); let iago = display_recipient.find((recipient) => recipient.email === "iago@zulip.com");
assert.equal(iago.full_name, "Iago"); assert.equal(iago.full_name, "Iago");
@@ -235,11 +235,6 @@ run_test("build_display_recipient", () => {
assert.equal(cordelia.full_name, "Cordelia"); assert.equal(cordelia.full_name, "Cordelia");
assert.equal(cordelia.id, 21); assert.equal(cordelia.id, 21);
const hamlet = display_recipient.find((recipient) => recipient.email === "hamlet@zulip.com");
assert.equal(hamlet.full_name, "hamlet@zulip.com");
assert.equal(hamlet.id, undefined);
assert.equal(hamlet.unknown_local_echo_user, true);
message = { message = {
type: "private", type: "private",
private_message_recipient: "iago@zulip.com", private_message_recipient: "iago@zulip.com",
@@ -341,7 +336,7 @@ run_test("insert_local_message direct message", ({override}) => {
let insert_message_called = false; let insert_message_called = false;
const insert_new_messages = ([message]) => { const insert_new_messages = ([message]) => {
assert.equal(message.display_recipient.length, 3); assert.equal(message.display_recipient.length, 2);
insert_message_called = true; insert_message_called = true;
return [message]; return [message];
}; };
@@ -351,7 +346,7 @@ run_test("insert_local_message direct message", ({override}) => {
}); });
const message_request = { const message_request = {
private_message_recipient: "cordelia@zulip.com,hamlet@zulip.com", private_message_recipient: "cordelia@zulip.com",
type: "private", type: "private",
sender_email: "iago@zulip.com", sender_email: "iago@zulip.com",
sender_full_name: "Iago", sender_full_name: "Iago",

View File

@@ -282,14 +282,6 @@ const stewie = {
}, },
}; };
// This is for error checking--never actually
// tell people.js about this user.
const invalid_user = {
email: "invalid@example.com",
user_id: 999,
unknown_local_echo_user: true,
};
function get_all_persons() { function get_all_persons() {
return people.filter_all_persons(() => true); return people.filter_all_persons(() => true);
} }
@@ -1012,7 +1004,7 @@ test_people("message_methods", () => {
}); });
test_people("extract_people_from_message", () => { test_people("extract_people_from_message", () => {
let message = { const message = {
type: "stream", type: "stream",
sender_full_name: maria.full_name, sender_full_name: maria.full_name,
sender_id: maria.user_id, sender_id: maria.user_id,
@@ -1024,13 +1016,6 @@ test_people("extract_people_from_message", () => {
people.extract_people_from_message(message); people.extract_people_from_message(message);
assert.ok(people.is_known_user_id(maria.user_id)); assert.ok(people.is_known_user_id(maria.user_id));
blueslip.reset(); blueslip.reset();
// Get line coverage
message = {
type: "private",
display_recipient: [invalid_user],
};
people.extract_people_from_message(message);
}); });
test_people("maybe_incr_recipient_count", () => { test_people("maybe_incr_recipient_count", () => {
@@ -1058,20 +1043,6 @@ test_people("maybe_incr_recipient_count", () => {
people.maybe_incr_recipient_count(message); people.maybe_incr_recipient_count(message);
assert.equal(people.get_recipient_count(maria), 1); assert.equal(people.get_recipient_count(maria), 1);
const other_invalid_recip = {
email: "invalid2@example.com",
id: 500,
unknown_local_echo_user: true,
};
message = {
type: "private",
sent_by_me: true,
display_recipient: [other_invalid_recip],
};
people.maybe_incr_recipient_count(message);
assert.equal(people.get_recipient_count(maria), 1);
message = { message = {
type: "stream", type: "stream",
}; };