[MM-40568] Do not strip notification text for all platforms (#26536)

* Do not strip notification text when using desktop app or webapp from linux

* Remove notification text triming for all OS

* 'strippedMarkdownNotifyText' is never reassigned. Use 'const' instead

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Julien Virey 2024-04-02 18:35:18 +04:00 committed by GitHub
parent ddbc84f6ce
commit ed58b10486
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,16 +27,11 @@ import MentionableRenderer from 'utils/markdown/mentionable_renderer';
import * as NotificationSounds from 'utils/notification_sounds'; import * as NotificationSounds from 'utils/notification_sounds';
import {showNotification} from 'utils/notifications'; import {showNotification} from 'utils/notifications';
import {cjkrPattern, escapeRegex} from 'utils/text_formatting'; import {cjkrPattern, escapeRegex} from 'utils/text_formatting';
import {isDesktopApp, isMobileApp, isWindowsApp} from 'utils/user_agent'; import {isDesktopApp, isMobileApp} from 'utils/user_agent';
import * as Utils from 'utils/utils'; import * as Utils from 'utils/utils';
import {runDesktopNotificationHooks} from './hooks'; import {runDesktopNotificationHooks} from './hooks';
const NOTIFY_TEXT_MAX_LENGTH = 50;
// windows notification length is based windows chrome which supports 128 characters and is the lowest length of windows browsers
const WINDOWS_NOTIFY_TEXT_MAX_LENGTH = 120;
const getSoundFromChannelMemberAndUser = (member, user) => { const getSoundFromChannelMemberAndUser = (member, user) => {
if (member?.notify_props?.desktop_sound) { if (member?.notify_props?.desktop_sound) {
return member.notify_props.desktop_sound === 'on'; return member.notify_props.desktop_sound === 'on';
@ -244,12 +239,7 @@ export function sendDesktopNotification(post, msgProps) {
image |= attachment.image_url.length > 0; image |= attachment.image_url.length > 0;
}); });
let strippedMarkdownNotifyText = stripMarkdown(notifyText); const strippedMarkdownNotifyText = stripMarkdown(notifyText);
const notifyTextMaxLength = isWindowsApp() ? WINDOWS_NOTIFY_TEXT_MAX_LENGTH : NOTIFY_TEXT_MAX_LENGTH;
if (strippedMarkdownNotifyText.length > notifyTextMaxLength) {
strippedMarkdownNotifyText = strippedMarkdownNotifyText.substring(0, notifyTextMaxLength - 1) + '...';
}
let body = `@${username}`; let body = `@${username}`;
if (strippedMarkdownNotifyText.length === 0) { if (strippedMarkdownNotifyText.length === 0) {