recent_topics: Fix exception processing old deleted messages.

When old messages are deleted, they may not be present in
message_store when we receive the event notifying the client about
their deletion.
This commit is contained in:
Tim Abbott
2020-08-06 11:58:21 -07:00
parent 483445e3d3
commit 5142bdd317
2 changed files with 11 additions and 1 deletions

View File

@@ -76,8 +76,13 @@ exports.process_topic_edit = function (old_stream_id, old_topic, new_topic, new_
exports.update_topics_of_message_ids = function (message_ids) {
const topics_to_update = new Map();
for (const msg_id of message_ids) {
// Note: message_store retians data of msg post deletion.
// message_store still has data on deleted messages when this runs.
const message = message_store.get(msg_id);
if (message === undefined) {
// We may not have the deleted message cached locally in
// message_store; if so, we can just skip processing it.
continue;
}
if (message.type === "stream") {
// Create unique keys for stream_id and topic.
const topic_key = message.stream_id + ":" + message.topic;

View File

@@ -238,6 +238,11 @@ exports.update_topics_of_message_ids = function (message_ids) {
const topics_to_rerender = new Map();
for (const msg_id of message_ids) {
const message = message_store.get(msg_id);
if (message === undefined) {
// We may not have the deleted message cached locally in
// message_store; if so, we can just skip processing it.
continue;
}
if (message.type === "stream") {
const topic_key = get_topic_key(message.stream_id, message.topic);
topics_to_rerender.set(topic_key, [message.stream_id, message.topic]);