mirror of
https://github.com/zulip/zulip.git
synced 2026-06-21 21:32:29 +08:00
recent_topics: Skip non-stream messages in update_topics_of_message_ids.
Fixes an exception when deleting a private message, introduced by
commit 5d5434ec2f (#15803).
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
96f579287a
commit
ea7effbe8a
@ -28,12 +28,14 @@ run_test("process_message_for_senders", () => {
|
||||
|
||||
// New stream
|
||||
const message1 = {
|
||||
type: "stream",
|
||||
stream_id: stream1,
|
||||
id: (next_id += 1),
|
||||
topic: topic1,
|
||||
sender_id: sender1,
|
||||
};
|
||||
const message2 = {
|
||||
type: "stream",
|
||||
stream_id: stream2,
|
||||
id: (next_id += 1),
|
||||
topic: topic1,
|
||||
@ -62,6 +64,7 @@ run_test("process_message_for_senders", () => {
|
||||
|
||||
// New topic
|
||||
const message3 = {
|
||||
type: "stream",
|
||||
stream_id: stream1,
|
||||
id: (next_id += 1),
|
||||
topic: topic2,
|
||||
@ -77,6 +80,7 @@ run_test("process_message_for_senders", () => {
|
||||
|
||||
// New sender
|
||||
const message4 = {
|
||||
type: "stream",
|
||||
stream_id: stream1,
|
||||
id: (next_id += 1),
|
||||
topic: topic1,
|
||||
@ -92,6 +96,7 @@ run_test("process_message_for_senders", () => {
|
||||
|
||||
// More recent message
|
||||
const message5 = {
|
||||
type: "stream",
|
||||
stream_id: stream1,
|
||||
id: (next_id += 1),
|
||||
topic: topic1,
|
||||
@ -107,18 +112,21 @@ run_test("process_message_for_senders", () => {
|
||||
|
||||
// Same stream, but different topics
|
||||
const message6 = {
|
||||
type: "stream",
|
||||
stream_id: stream3,
|
||||
id: (next_id += 1),
|
||||
topic: topic1,
|
||||
sender_id: sender1,
|
||||
};
|
||||
const message7 = {
|
||||
type: "stream",
|
||||
stream_id: stream3,
|
||||
id: (next_id += 1),
|
||||
topic: topic2,
|
||||
sender_id: sender2,
|
||||
};
|
||||
const message8 = {
|
||||
type: "stream",
|
||||
stream_id: stream3,
|
||||
id: (next_id += 1),
|
||||
topic: topic3,
|
||||
@ -144,6 +152,7 @@ run_test("process_message_for_senders", () => {
|
||||
|
||||
// new message in topic2
|
||||
const message9 = {
|
||||
type: "stream",
|
||||
stream_id: stream3,
|
||||
id: (next_id += 1),
|
||||
topic: topic2,
|
||||
|
||||
@ -76,9 +76,11 @@ exports.update_topics_of_message_ids = function (message_ids) {
|
||||
for (const msg_id of message_ids) {
|
||||
// Note: message_store retians data of msg post deletion.
|
||||
const message = message_store.get(msg_id);
|
||||
// Create unique keys for stream_id and topic.
|
||||
const topic_key = message.stream_id + ":" + message.topic;
|
||||
topics_to_update.set(topic_key, [message.stream_id, message.topic]);
|
||||
if (message.type === "stream") {
|
||||
// Create unique keys for stream_id and topic.
|
||||
const topic_key = message.stream_id + ":" + message.topic;
|
||||
topics_to_update.set(topic_key, [message.stream_id, message.topic]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [stream_id, topic] of topics_to_update.values()) {
|
||||
|
||||
@ -242,8 +242,10 @@ 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);
|
||||
const topic_key = get_topic_key(message.stream_id, message.topic);
|
||||
topics_to_rerender.set(topic_key, [message.stream_id, message.topic]);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [stream_id, topic] of topics_to_rerender.values()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user