mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
refactor: Move pm_conversations.process_message.
I lift this function out of message_store to
break some dependencies, and it's also more
consistent with the rest of the codebase:
alert_words.process_message
pm_conversations.process_message
recent_topics.process_messages
recent_senders.process_message_for_senders
We can do further cleanup to make these names
consistent (and possibly have them all work in
bulk), but that's out of the scope of the current PR.
This commit is contained in:
@@ -233,7 +233,7 @@ test("errors", () => {
|
||||
"set_partner",
|
||||
() => assert(false),
|
||||
() => {
|
||||
message_store.process_message_for_recent_private_messages(message);
|
||||
pm_conversations.process_message(message);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as alert_words from "./alert_words";
|
||||
import * as message_store from "./message_store";
|
||||
import * as message_user_ids from "./message_user_ids";
|
||||
import * as people from "./people";
|
||||
import * as pm_conversations from "./pm_conversations";
|
||||
import * as recent_senders from "./recent_senders";
|
||||
import * as stream_topic_history from "./stream_topic_history";
|
||||
import * as util from "./util";
|
||||
@@ -59,7 +60,7 @@ export function process_new_message(message) {
|
||||
message.pm_with_url = people.pm_with_url(message);
|
||||
message.to_user_ids = people.pm_reply_user_string(message);
|
||||
|
||||
message_store.process_message_for_recent_private_messages(message);
|
||||
pm_conversations.process_message(message);
|
||||
|
||||
if (people.is_my_user_id(message.sender_id)) {
|
||||
for (const recip of message.display_recipient) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as blueslip from "./blueslip";
|
||||
import * as message_list from "./message_list";
|
||||
import * as people from "./people";
|
||||
import * as pm_conversations from "./pm_conversations";
|
||||
|
||||
const stored_messages = new Map();
|
||||
|
||||
@@ -69,19 +68,6 @@ export function get_pm_full_names(message) {
|
||||
return names.join(", ");
|
||||
}
|
||||
|
||||
export function process_message_for_recent_private_messages(message) {
|
||||
const user_ids = people.pm_with_user_ids(message);
|
||||
if (!user_ids) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const user_id of user_ids) {
|
||||
pm_conversations.set_partner(user_id);
|
||||
}
|
||||
|
||||
pm_conversations.recent.insert(user_ids, message.id);
|
||||
}
|
||||
|
||||
export function set_message_booleans(message) {
|
||||
const flags = message.flags || [];
|
||||
|
||||
|
||||
@@ -77,6 +77,19 @@ class RecentPrivateMessages {
|
||||
|
||||
export let recent = new RecentPrivateMessages();
|
||||
|
||||
export function process_message(message) {
|
||||
const user_ids = people.pm_with_user_ids(message);
|
||||
if (!user_ids) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const user_id of user_ids) {
|
||||
set_partner(user_id);
|
||||
}
|
||||
|
||||
recent.insert(user_ids, message.id);
|
||||
}
|
||||
|
||||
export function clear_for_testing() {
|
||||
recent = new RecentPrivateMessages();
|
||||
partners.clear();
|
||||
|
||||
Reference in New Issue
Block a user