From fdac13ba24db0dd591bdf07f9d8a87492739bae9 Mon Sep 17 00:00:00 2001 From: Daniil Fadeev Date: Wed, 26 Jul 2023 19:19:56 +0300 Subject: [PATCH] notifications: Extract `notification_source` debugging logic. This commit aims to extract all logic related to debugging the value of `notification_source` from the `process_notification` function into a separate `debug_notification_source_value` function. --- web/src/notifications.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/web/src/notifications.js b/web/src/notifications.js index b7c5940e4a..6e118dc93a 100644 --- a/web/src/notifications.js +++ b/web/src/notifications.js @@ -229,6 +229,22 @@ function get_notification_content(message) { return content; } +function debug_notification_source_value(message) { + let notification_source; + + if (message.type === "private" || message.type === "test-notification") { + notification_source = "pm"; + } else if (message.mentioned) { + notification_source = "mention"; + } else if (message.alerted) { + notification_source = "alert"; + } else { + notification_source = "stream"; + } + + blueslip.debug("Desktop notification from source " + notification_source); +} + export function process_notification(notification) { let notification_object; let key; @@ -237,29 +253,21 @@ export function process_notification(notification) { let other_recipients; let title = message.sender_full_name; let msg_count = 1; - let notification_source; const topic = message.topic; + debug_notification_source_value(message); + if (message.type === "private" || message.type === "test-notification") { key = message.display_reply_to; // Remove the sender from the list of other recipients other_recipients = `, ${message.display_reply_to}, ` .replace(`, ${message.sender_full_name}, `, ", ") .slice(", ".length, -", ".length); - notification_source = "pm"; } else { const stream_name = stream_data.get_stream_name_from_id(message.stream_id); key = message.sender_full_name + " to " + stream_name + " > " + topic; - if (message.mentioned) { - notification_source = "mention"; - } else if (message.alerted) { - notification_source = "alert"; - } else { - notification_source = "stream"; - } } - blueslip.debug("Desktop notification from source " + notification_source); if (notice_memory.has(key)) { msg_count = notice_memory.get(key).msg_count + 1;