Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

hash_util: Use user_id instead of email to generate DM emails.

Aman Agrawala13f4e48327d
diff --git a/web/src/buddy_data.ts b/web/src/buddy_data.ts
index 2b7caa6b9ee..276668bd7e6 100644
--- a/web/src/buddy_data.ts
+++ b/web/src/buddy_data.ts
@@ -231,7 +231,7 @@ export function info_for(user_id: number, direct_message_recipients: Set<number>
};
return {
- href: hash_util.pm_with_url(person.email),
+ href: hash_util.pm_with_url(person.user_id.toString()),
name: person.full_name,
user_id,
status_emoji_info,
diff --git a/web/src/hash_util.ts b/web/src/hash_util.ts
index 966a4dc3191..d2fdc5e1a21 100644
--- a/web/src/hash_util.ts
+++ b/web/src/hash_util.ts
@@ -162,8 +162,8 @@ export function by_sender_url(reply_to: string): string {
return search_terms_to_hash([{operator: "sender", operand: reply_to}]);
}
-export function pm_with_url(reply_to: string): string {
- const slug = people.emails_to_slug(reply_to);
+export function pm_with_url(user_ids_string: string): string {
+ const slug = people.user_ids_string_to_slug(user_ids_string);
return "#narrow/dm/" + slug;
}
diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.ts
index cc7a28de94b..cc847d53424 100644
--- a/web/src/inbox_ui.ts
+++ b/web/src/inbox_ui.ts
@@ -469,8 +469,6 @@ function format_dm(
recipient_ids.push(people.my_current_user_id());
}
- const reply_to = people.user_ids_string_to_emails_string(user_ids_string);
- assert(reply_to !== undefined);
const rendered_dm_with_html = recipient_ids
.map((recipient_id) => ({
name: people.get_display_full_name(recipient_id),
@@ -501,7 +499,7 @@ function format_dm(
is_group: recipient_ids.length > 1,
user_circle_class,
is_bot,
- dm_url: hash_util.pm_with_url(reply_to),
+ dm_url: hash_util.pm_with_url(user_ids_string),
user_ids_string,
unread_count,
is_hidden: filter_should_hide_dm_row({dm_key: user_ids_string}),
diff --git a/web/src/pm_list_data.ts b/web/src/pm_list_data.ts
index c6664a52a73..fb7ceab9d1e 100644
--- a/web/src/pm_list_data.ts
+++ b/web/src/pm_list_data.ts
@@ -1,5 +1,3 @@
-import assert from "minimalistic-assert";
-
import * as buddy_data from "./buddy_data.ts";
import * as hash_util from "./hash_util.ts";
import * as narrow_state from "./narrow_state.ts";
@@ -79,8 +77,6 @@ export function get_conversations(search_string = ""): DisplayObject[] {
continue;
}
- const reply_to = people.user_ids_string_to_emails_string(user_ids_string);
- assert(reply_to !== undefined);
const recipients_string = people.format_recipients(user_ids_string, "narrow");
const num_unread = unread.num_unread_for_user_ids_string(user_ids_string);
@@ -117,7 +113,7 @@ export function get_conversations(search_string = ""): DisplayObject[] {
unread: num_unread,
is_zero: num_unread === 0,
is_active,
- url: hash_util.pm_with_url(reply_to),
+ url: hash_util.pm_with_url(user_ids_string),
status_emoji_info,
user_circle_class,
is_group,
diff --git a/web/src/user_card_popover.ts b/web/src/user_card_popover.ts
index dbcab3ceea6..5138c455e3f 100644
--- a/web/src/user_card_popover.ts
+++ b/web/src/user_card_popover.ts
@@ -355,7 +355,7 @@ function get_user_card_popover_data(
is_bot: user.is_bot,
is_me,
is_sender_popover,
- pm_with_url: hash_util.pm_with_url(user.email),
+ pm_with_url: hash_util.pm_with_url(user.user_id.toString()),
user_circle_class: buddy_data.get_user_circle_class(user.user_id),
private_message_class: private_msg_class,
sent_by_url: hash_util.by_sender_url(user.email),
diff --git a/web/tests/message_view.test.cjs b/web/tests/message_view.test.cjs
index 5196e4fb4ad..a8579f21539 100644
--- a/web/tests/message_view.test.cjs
+++ b/web/tests/message_view.test.cjs
@@ -207,7 +207,7 @@ run_test("urls", () => {
people.add_active_user(me);
people.initialize_current_user(me.user_id);
- let url = hash_util.pm_with_url(ray.email);
+ let url = hash_util.pm_with_url(ray.user_id.toString());
assert.equal(url, "#narrow/dm/22-Raymond");
url = hash_util.direct_message_group_with_url("22,23");