From f84de2212e4190d2dbaec9ce804079808db86d6c Mon Sep 17 00:00:00 2001 From: Lakshay Mittal Date: Sat, 1 Apr 2023 00:47:46 +0530 Subject: [PATCH] notifications: Fix blank notification sent when no text specified. When we send a message (for which notifications are enabled) in format `[](file_url)`. A blank notification is sent. Fixing this by checking if there is no text and adding message in that case. Inspired from: #8796. Fixes: #8087. --- web/src/notifications.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web/src/notifications.js b/web/src/notifications.js index fd22e0e4c7..cfc5d01016 100644 --- a/web/src/notifications.js +++ b/web/src/notifications.js @@ -10,6 +10,7 @@ import * as favicon from "./favicon"; import * as hash_util from "./hash_util"; import {$t} from "./i18n"; import * as message_lists from "./message_lists"; +import * as message_parser from "./message_parser"; import * as message_store from "./message_store"; import * as narrow from "./narrow"; import * as narrow_state from "./narrow_state"; @@ -241,7 +242,16 @@ export function process_notification(notification) { const $content = $("
").html(message.content); ui.replace_emoji_with_text($content); spoilers.hide_spoilers_in_notification($content); - content = $content.text(); + + if ( + $content.text().trim() === "" && + (message_parser.message_has_image(message) || + message_parser.message_has_attachment(message)) + ) { + content = $t({defaultMessage: "(attached file)"}); + } else { + content = $content.text(); + } const topic = message.topic;