diff --git a/apps/meteor/app/autotranslate/client/lib/autotranslate.ts b/apps/meteor/app/autotranslate/client/lib/autotranslate.ts index 76b45d04e18fa..c7818db2b161d 100644 --- a/apps/meteor/app/autotranslate/client/lib/autotranslate.ts +++ b/apps/meteor/app/autotranslate/client/lib/autotranslate.ts @@ -70,16 +70,6 @@ export const AutoTranslate = { } } - if (attachment.description && attachment.translations && attachment.translations[language]) { - attachment.translations.original = attachment.description; - - if (autoTranslateShowInverse) { - attachment.description = attachment.translations.original; - } else { - attachment.description = attachment.translations[language]; - } - } - // @ts-expect-error - not sure what to do with this if (attachment.attachments && attachment.attachments.length > 0) { // @ts-expect-error - not sure what to do with this diff --git a/apps/meteor/app/autotranslate/server/autotranslate.ts b/apps/meteor/app/autotranslate/server/autotranslate.ts index 2f91e02463d58..3e04f6d39eb30 100644 --- a/apps/meteor/app/autotranslate/server/autotranslate.ts +++ b/apps/meteor/app/autotranslate/server/autotranslate.ts @@ -320,7 +320,7 @@ export abstract class AutoTranslate { if (message.attachments && message.attachments.length > 0) { setImmediate(async () => { for (const [index, attachment] of message.attachments?.entries() ?? []) { - if (attachment.description || attachment.text) { + if (attachment.text) { // Removes the initial link `[ ](quoterl)` from quote message before translation const translatedText = attachment?.text?.replace(/\[(.*?)\]\(.*?\)/g, '$1') || attachment?.text; const attachmentMessage = { ...attachment, text: translatedText }; diff --git a/apps/meteor/app/autotranslate/server/deeplTranslate.ts b/apps/meteor/app/autotranslate/server/deeplTranslate.ts index d76a7ea2e4901..35f73e1755da6 100644 --- a/apps/meteor/app/autotranslate/server/deeplTranslate.ts +++ b/apps/meteor/app/autotranslate/server/deeplTranslate.ts @@ -196,7 +196,7 @@ class DeeplAutoTranslate extends AutoTranslate { params: { auth_key: this.apiKey, target_lang: language, - text: attachment.description || attachment.text || '', + text: attachment.text || '', }, }); if (!result.ok) { diff --git a/apps/meteor/app/autotranslate/server/googleTranslate.ts b/apps/meteor/app/autotranslate/server/googleTranslate.ts index 9667ae53c967a..53b9bb7c1d5ea 100644 --- a/apps/meteor/app/autotranslate/server/googleTranslate.ts +++ b/apps/meteor/app/autotranslate/server/googleTranslate.ts @@ -195,7 +195,7 @@ class GoogleAutoTranslate extends AutoTranslate { key: this.apiKey, target: language, format: 'text', - q: attachment.description || attachment.text || '', + q: attachment.text || '', }, }); if (!result.ok) { diff --git a/apps/meteor/app/autotranslate/server/msTranslate.ts b/apps/meteor/app/autotranslate/server/msTranslate.ts index ddb345d3c895a..6508734a1c0da 100644 --- a/apps/meteor/app/autotranslate/server/msTranslate.ts +++ b/apps/meteor/app/autotranslate/server/msTranslate.ts @@ -192,7 +192,7 @@ class MsAutoTranslate extends AutoTranslate { return this._translate( [ { - Text: attachment.description || attachment.text || '', + Text: attachment.text || '', }, ], targetLanguages, diff --git a/apps/meteor/app/lib/server/functions/notifications/email.js b/apps/meteor/app/lib/server/functions/notifications/email.js index a27699bc1d111..7bdbd0d6e990a 100644 --- a/apps/meteor/app/lib/server/functions/notifications/email.js +++ b/apps/meteor/app/lib/server/functions/notifications/email.js @@ -77,13 +77,8 @@ export async function getEmailContent({ message, user, room }) { } if (hasFiles) { - const attachments = message.attachments || []; - const fileParts = files.map((file, index) => { - let part = escapeHTML(file.name); - if (attachments[index]?.description) { - part += `

${escapeHTML(attachments[index].description)}`; - } - return part; + const fileParts = files.map((file) => { + return escapeHTML(file.name); }); contentParts.push(fileParts.join('

')); } diff --git a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts index 7a089abba0815..498cef1624624 100644 --- a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts +++ b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts @@ -195,8 +195,6 @@ export const sendNotification = async ({ const firstAttachment = message.attachments?.length && message.attachments.shift(); if (firstAttachment) { - firstAttachment.description = - typeof firstAttachment.description === 'string' ? emojione.shortnameToUnicode(firstAttachment.description) : undefined; firstAttachment.text = typeof firstAttachment.text === 'string' ? emojione.shortnameToUnicode(firstAttachment.text) : undefined; } diff --git a/apps/meteor/app/lib/server/methods/updateMessage.ts b/apps/meteor/app/lib/server/methods/updateMessage.ts index 45ba42f25f000..833b4403c0eca 100644 --- a/apps/meteor/app/lib/server/methods/updateMessage.ts +++ b/apps/meteor/app/lib/server/methods/updateMessage.ts @@ -34,7 +34,7 @@ export async function executeUpdateMessage( // IF the message has custom fields, always update // Ideally, we'll compare the custom fields to check for change, but since we don't know the shape of // custom fields, as it's user defined, we're gonna update - const msgText = originalMessage?.attachments?.[0]?.description ?? originalMessage.msg; + const msgText = originalMessage.msg; if (msgText === message.msg && !previewUrls && !message.customFields) { return; } @@ -86,13 +86,6 @@ export async function executeUpdateMessage( } await canSendMessageAsync(message.rid, { uid: user._id, username: user.username ?? undefined, ...user }); - // It is possible to have an empty array as the attachments property, so ensure both things exist - if (originalMessage.attachments && originalMessage.attachments.length > 0 && originalMessage.attachments[0].description !== undefined) { - originalMessage.attachments[0].description = message.msg; - message.attachments = originalMessage.attachments; - message.msg = originalMessage.msg; - } - message.u = originalMessage.u; return updateMessage(message, user, originalMessage, previewUrls); diff --git a/apps/meteor/app/livechat/server/lib/sendTranscript.ts b/apps/meteor/app/livechat/server/lib/sendTranscript.ts index 199275f6a516b..f52ac3f516710 100644 --- a/apps/meteor/app/livechat/server/lib/sendTranscript.ts +++ b/apps/meteor/app/livechat/server/lib/sendTranscript.ts @@ -108,7 +108,7 @@ export async function sendTranscript({ const messageType = MessageTypes.getType(message); - let messageContent = messageType?.system + const messageContent = messageType?.system ? DOMPurify.sanitize(` ${messageType.text(i18n.cloneInstance({ interpolation: { escapeValue: false } }).t, message)}}`) : escapeHtml(message.msg); @@ -116,9 +116,6 @@ export async function sendTranscript({ let filesHTML = ''; if (message.attachments && message.attachments?.length > 0) { - messageContent = message.attachments[0].description || ''; - escapeHtml(messageContent); - for await (const attachment of message.attachments) { if (!isFileAttachment(attachment)) { continue; diff --git a/apps/meteor/app/slackbridge/server/RocketAdapter.ts b/apps/meteor/app/slackbridge/server/RocketAdapter.ts index 925bb4ef2dc4d..cdf4cd8085af9 100644 --- a/apps/meteor/app/slackbridge/server/RocketAdapter.ts +++ b/apps/meteor/app/slackbridge/server/RocketAdapter.ts @@ -203,14 +203,11 @@ export default class RocketAdapter { if (rocketMessage.file.name) { let fileName = rocketMessage.file.name; - let text = rocketMessage.msg; + const text = rocketMessage.msg; const attachment = this.getMessageAttachment(rocketMessage); if (attachment) { fileName = Meteor.absoluteUrl(attachment.title_link); - if (!text) { - text = attachment.description; - } } await slack.postMessage(slack.getSlackChannel(rocketMessage.rid), { ...rocketMessage, msg: `${text} ${fileName}` }); diff --git a/apps/meteor/app/ui/client/lib/ChatMessages.ts b/apps/meteor/app/ui/client/lib/ChatMessages.ts index a6febf3fdfef9..70b64201979ba 100644 --- a/apps/meteor/app/ui/client/lib/ChatMessages.ts +++ b/apps/meteor/app/ui/client/lib/ChatMessages.ts @@ -120,7 +120,7 @@ export class ChatMessages implements ChatAPI { }, editMessage: async (message: IMessage, { cursorAtStart = false }: { cursorAtStart?: boolean } = {}) => { this.composer?.uploads.clear(); - const text = (await this.data.getDraft(message._id)) || message.attachments?.[0]?.description || message.msg; + const text = (await this.data.getDraft(message._id)) || message.msg; await this.currentEditingMessage.stop(); diff --git a/apps/meteor/client/components/message/content/attachments/file/AudioAttachment.tsx b/apps/meteor/client/components/message/content/attachments/file/AudioAttachment.tsx index 227874cfb8eaf..9fa94126127e8 100644 --- a/apps/meteor/client/components/message/content/attachments/file/AudioAttachment.tsx +++ b/apps/meteor/client/components/message/content/attachments/file/AudioAttachment.tsx @@ -4,17 +4,13 @@ import { useMediaUrl } from '@rocket.chat/ui-contexts'; import { useMemo } from 'react'; import { useReloadOnError } from './hooks/useReloadOnError'; -import MarkdownText from '../../../../MarkdownText'; import MessageCollapsible from '../../../MessageCollapsible'; -import MessageContentBody from '../../../MessageContentBody'; const AudioAttachment = ({ title, audio_url: url, audio_type: type, audio_size: size, - description, - descriptionMd, title_link: link, title_link_download: hasDownload, collapsed, @@ -25,7 +21,6 @@ const AudioAttachment = ({ return ( <> - {descriptionMd ? : } diff --git a/apps/meteor/client/components/message/content/attachments/file/GenericFileAttachment.tsx b/apps/meteor/client/components/message/content/attachments/file/GenericFileAttachment.tsx index d2dbd4f888257..2e0fb7107d983 100644 --- a/apps/meteor/client/components/message/content/attachments/file/GenericFileAttachment.tsx +++ b/apps/meteor/client/components/message/content/attachments/file/GenericFileAttachment.tsx @@ -13,9 +13,7 @@ import { useTranslation } from 'react-i18next'; import { getFileExtension } from '../../../../../../lib/utils/getFileExtension'; import { forAttachmentDownload, registerDownloadForUid } from '../../../../../hooks/useDownloadFromServiceWorker'; -import MarkdownText from '../../../../MarkdownText'; import MessageCollapsible from '../../../MessageCollapsible'; -import MessageContentBody from '../../../MessageContentBody'; import AttachmentSize from '../structure/AttachmentSize'; const openDocumentViewer = window.RocketChatDesktop?.openDocumentViewer; @@ -24,8 +22,6 @@ type GenericFileAttachmentProps = MessageAttachmentBase; const GenericFileAttachment = ({ title, - description, - descriptionMd, title_link: link, title_link_download: hasDownload, size, @@ -72,7 +68,6 @@ const GenericFileAttachment = ({ return ( <> - {descriptionMd ? : } - {descriptionMd ? : } - {descriptionMd ? : } diff --git a/apps/meteor/client/components/message/toolbar/useCopyAction.ts b/apps/meteor/client/components/message/toolbar/useCopyAction.ts index 1a03dac99936d..b8275144abca1 100644 --- a/apps/meteor/client/components/message/toolbar/useCopyAction.ts +++ b/apps/meteor/client/components/message/toolbar/useCopyAction.ts @@ -6,8 +6,8 @@ import type { MessageActionConfig } from '../../../../app/ui-utils/client/lib/Me const getMainMessageText = (message: IMessage): IMessage => { const newMessage = { ...message }; - newMessage.msg = newMessage.msg || newMessage.attachments?.[0]?.description || newMessage.attachments?.[0]?.title || ''; - newMessage.md = newMessage.md || newMessage.attachments?.[0]?.descriptionMd || undefined; + newMessage.msg = newMessage.msg || newMessage.attachments?.[0]?.title || ''; + newMessage.md = newMessage.md || undefined; return { ...newMessage }; }; diff --git a/apps/meteor/client/components/message/toolbar/useReportMessageAction.tsx b/apps/meteor/client/components/message/toolbar/useReportMessageAction.tsx index ba281c5a1f5a2..dbbb962032907 100644 --- a/apps/meteor/client/components/message/toolbar/useReportMessageAction.tsx +++ b/apps/meteor/client/components/message/toolbar/useReportMessageAction.tsx @@ -7,8 +7,8 @@ import ReportMessageModal from '../../../views/room/modals/ReportMessageModal'; const getMainMessageText = (message: IMessage): IMessage => { const newMessage = { ...message }; - newMessage.msg = newMessage.msg || newMessage.attachments?.[0]?.description || newMessage.attachments?.[0]?.title || ''; - newMessage.md = newMessage.md || newMessage.attachments?.[0]?.descriptionMd || undefined; + newMessage.msg = newMessage.msg || newMessage.attachments?.[0]?.title || ''; + newMessage.md = newMessage.md || undefined; return { ...newMessage }; }; diff --git a/apps/meteor/client/hooks/useDecryptedMessage.spec.ts b/apps/meteor/client/hooks/useDecryptedMessage.spec.ts index 5b35e8d6e3352..3103e708910f6 100644 --- a/apps/meteor/client/hooks/useDecryptedMessage.spec.ts +++ b/apps/meteor/client/hooks/useDecryptedMessage.spec.ts @@ -53,7 +53,7 @@ describe('useDecryptedMessage', () => { it('should handle E2EE messages with attachments', async () => { (isE2EEMessage as jest.MockedFunction).mockReturnValue(true); (e2e.decryptMessage as jest.Mock).mockResolvedValue({ - attachments: [{ description: 'Attachment description' }], + attachments: [{ title: 'Attachment title' }], }); const message = { msg: 'Encrypted message with attachment' }; @@ -63,7 +63,6 @@ describe('useDecryptedMessage', () => { expect(result.current).toBe('E2E_message_encrypted_placeholder'); }); - expect(result.current).toBe('Attachment description'); expect(e2e.decryptMessage).toHaveBeenCalledWith(message); }); diff --git a/apps/meteor/client/hooks/useDecryptedMessage.ts b/apps/meteor/client/hooks/useDecryptedMessage.ts index e560aacc5b111..771665dc0b631 100644 --- a/apps/meteor/client/hooks/useDecryptedMessage.ts +++ b/apps/meteor/client/hooks/useDecryptedMessage.ts @@ -18,14 +18,11 @@ export const useDecryptedMessage = (message: IMessage): string => { e2e.decryptMessage(message).then((decryptedMsg) => { if (decryptedMsg.msg) { setDecryptedMessage(decryptedMsg.msg); + return; } - if (decryptedMsg.attachments && decryptedMsg.attachments?.length > 0) { - if (decryptedMsg.attachments[0].description) { - setDecryptedMessage(decryptedMsg.attachments[0].description); - } else { - setDecryptedMessage(t('Message_with_attachment')); - } + if (decryptedMsg.attachments && decryptedMsg.attachments.length > 0) { + setDecryptedMessage(t('Message_with_attachment')); } }); }, [message, t, setDecryptedMessage]); diff --git a/apps/meteor/client/lib/normalizeThreadMessage.tsx b/apps/meteor/client/lib/normalizeThreadMessage.tsx index 1efa853f3679e..7f13803d2f80a 100644 --- a/apps/meteor/client/lib/normalizeThreadMessage.tsx +++ b/apps/meteor/client/lib/normalizeThreadMessage.tsx @@ -25,11 +25,7 @@ export function normalizeThreadMessage({ ...message }: Readonly attachment.title || attachment.description); - - if (attachment?.description) { - return <>{attachment.description}; - } + const attachment = message.attachments.find((attachment) => attachment.title); if (attachment?.title) { return <>{attachment.title}; diff --git a/apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts b/apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts index e48eb15f885cf..0105608949b7f 100644 --- a/apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts +++ b/apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts @@ -178,47 +178,6 @@ describe('parseMessageTextToAstMarkdown', () => { }); it('should return correct attachment translated parsed md when translate is active', () => { - const attachmentTranslatedMessage = { - ...translatedMessage, - attachments: [ - { - description: 'description', - translations: { - en: 'description translated', - }, - }, - ], - }; - const attachmentTranslatedMessageParsed = { - ...translatedMessage, - md: translatedMessageParsed, - attachments: [ - { - description: 'description', - translations: { - en: 'description translated', - }, - md: [ - { - type: 'PARAGRAPH', - value: [ - { - type: 'PLAIN_TEXT', - value: 'description translated', - }, - ], - }, - ], - }, - ], - }; - - expect(parseMessageTextToAstMarkdown(attachmentTranslatedMessage, parseOptions, enabledAutoTranslatedOptions)).toStrictEqual( - attachmentTranslatedMessageParsed, - ); - }); - - it('should return correct attachment quote translated parsed md when translate is active', () => { const attachmentTranslatedMessage = { ...translatedMessage, attachments: [ @@ -378,7 +337,7 @@ describe('parseMessageAttachments', () => { const attachmentMessage = [ { - description: 'message **bold** _italic_ and ~strike~', + text: 'message **bold** _italic_ and ~strike~', md: messageParserTokenMessage, }, ]; @@ -400,46 +359,18 @@ describe('parseMessageAttachments', () => { autoTranslateLanguage: 'en', }; - it('should return correct attachment description translated parsed md when translate is active', () => { - const descriptionAttachment = [ - { - ...attachmentMessage[0], - description: 'attachment not translated', - translationProvider: 'provider', - translations: { - en: 'attachment translated', - }, - }, - ]; - const descriptionAttachmentParsed: Root = [ - { - type: 'PARAGRAPH', - value: [ - { - type: 'PLAIN_TEXT', - value: 'attachment translated', - }, - ], - }, - ]; - - expect(parseMessageAttachments(descriptionAttachment, parseOptions, enabledAutoTranslatedOptions)[0].md).toStrictEqual( - descriptionAttachmentParsed, - ); - }); - - it('should return correct attachment description parsed md when translate is active and auto translate language is undefined', () => { - const descriptionAttachment = [ + it('should return correct attachment text parsed md when translate is active and auto translate language is undefined', () => { + const textAttachment = [ { ...attachmentMessage[0], - description: 'attachment not translated', + text: 'attachment not translated', translationProvider: 'provider', translations: { en: 'attachment translated', }, }, ]; - const descriptionAttachmentParsed: Root = [ + const textAttachmentParsed: Root = [ { type: 'PARAGRAPH', value: [ @@ -452,39 +383,11 @@ describe('parseMessageAttachments', () => { ]; expect( - parseMessageAttachments(descriptionAttachment, parseOptions, { + parseMessageAttachments(textAttachment, parseOptions, { ...enabledAutoTranslatedOptions, autoTranslateLanguage: undefined, })[0].md, - ).toStrictEqual(descriptionAttachmentParsed); - }); - - it('should return correct attachment text translated parsed md when translate is active', () => { - const textAttachment = [ - { - ...attachmentMessage[0], - text: 'attachment not translated', - translationProvider: 'provider', - translations: { - en: 'attachment translated', - }, - }, - ]; - const textAttachmentParsed: Root = [ - { - type: 'PARAGRAPH', - value: [ - { - type: 'PLAIN_TEXT', - value: 'attachment translated', - }, - ], - }, - ]; - - expect(parseMessageAttachments(textAttachment, parseOptions, enabledAutoTranslatedOptions)[0].md).toStrictEqual( - textAttachmentParsed, - ); + ).toStrictEqual(textAttachmentParsed); }); it('should return correct attachment text translated parsed md when translate is active and has multiple texts', () => { diff --git a/apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts b/apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts index df84785e26351..55d393cee38ed 100644 --- a/apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts +++ b/apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts @@ -1,12 +1,5 @@ import type { IMessage, ITranslatedMessage, MessageAttachment } from '@rocket.chat/core-typings'; -import { - isFileAttachment, - isE2EEMessage, - isQuoteAttachment, - isTranslatedAttachment, - isTranslatedMessage, - isEncryptedMessageAttachment, -} from '@rocket.chat/core-typings'; +import { isE2EEMessage, isQuoteAttachment, isTranslatedAttachment, isTranslatedMessage } from '@rocket.chat/core-typings'; import type { Options, Root } from '@rocket.chat/message-parser'; import { parse } from '@rocket.chat/message-parser'; @@ -58,7 +51,7 @@ export const parseMessageAttachment = ( autoTranslateOptions: { autoTranslateLanguage?: string; translated: boolean }, ): T => { const { translated, autoTranslateLanguage } = autoTranslateOptions; - if (!attachment.text && !attachment.description) { + if (!attachment.text) { return attachment; } @@ -69,16 +62,8 @@ export const parseMessageAttachment = ( const text = (isTranslatedAttachment(attachment) && autoTranslateLanguage && attachment?.translations?.[autoTranslateLanguage]) || attachment.text || - attachment.description || ''; - if (isFileAttachment(attachment) && attachment.description) { - attachment.descriptionMd = - translated || isEncryptedMessageAttachment(attachment) - ? textToMessageToken(text, parseOptions) - : (attachment.descriptionMd ?? textToMessageToken(text, parseOptions)); - } - return { ...attachment, md: translated ? textToMessageToken(text, parseOptions) : (attachment.md ?? textToMessageToken(text, parseOptions)), diff --git a/apps/meteor/client/lib/utils/normalizeMessagePreview/normalizeMessagePreview.spec.ts b/apps/meteor/client/lib/utils/normalizeMessagePreview/normalizeMessagePreview.spec.ts index 184145a6c4506..9584c13531439 100644 --- a/apps/meteor/client/lib/utils/normalizeMessagePreview/normalizeMessagePreview.spec.ts +++ b/apps/meteor/client/lib/utils/normalizeMessagePreview/normalizeMessagePreview.spec.ts @@ -48,7 +48,7 @@ describe('normalizeMessagePreview', () => { }); describe('when message has attachments', () => { - it('should return attachment description when available', () => { + it('should return attachment title when description is available', () => { const message = createFakeMessageWithAttachment({ msg: '', attachments: [ @@ -60,10 +60,10 @@ describe('normalizeMessagePreview', () => { }); const result = normalizeMessagePreview(message, mockT); - expect(result).toBe('Attachment description'); + expect(result).toBe('Attachment title'); }); - it('should return attachment title when description is not available', () => { + it('should return attachment title when message is not provided', () => { const message = createFakeMessageWithAttachment({ msg: '', attachments: [ @@ -112,7 +112,7 @@ describe('normalizeMessagePreview', () => { expect(result).toBe('Second attachment title'); }); - it('should find first attachment description', () => { + it('should find first attachment title', () => { const message = createFakeMessageWithAttachment({ msg: '', attachments: [ @@ -129,21 +129,7 @@ describe('normalizeMessagePreview', () => { }); const result = normalizeMessagePreview(message, mockT); - expect(result).toBe('Second attachment description'); - }); - - it('should escape HTML in attachment description', () => { - const message = createFakeMessageWithAttachment({ - msg: '', - attachments: [ - { - description: '', - }, - ], - }); - const result = normalizeMessagePreview(message, mockT); - - expect(result).toBe('<script>alert("xss")</script>'); + expect(result).toBe('Third attachment title'); }); it('should escape HTML in attachment title', () => { diff --git a/apps/meteor/client/lib/utils/normalizeMessagePreview/normalizeMessagePreview.ts b/apps/meteor/client/lib/utils/normalizeMessagePreview/normalizeMessagePreview.ts index 53bf5bf2d4056..0fbefea5fa48d 100644 --- a/apps/meteor/client/lib/utils/normalizeMessagePreview/normalizeMessagePreview.ts +++ b/apps/meteor/client/lib/utils/normalizeMessagePreview/normalizeMessagePreview.ts @@ -11,11 +11,7 @@ export const normalizeMessagePreview = (message: IMessage, t: TFunction): string } if (message.attachments) { - const attachment = message.attachments.find((attachment) => attachment.title || attachment.description); - - if (attachment?.description) { - return escapeHTML(attachment.description); - } + const attachment = message.attachments.find((attachment) => attachment.title); if (attachment?.title) { return escapeHTML(attachment.title); diff --git a/apps/meteor/client/views/room/MessageList/hooks/useMessageBody.tsx b/apps/meteor/client/views/room/MessageList/hooks/useMessageBody.tsx index 0bcbbccece740..94313e6925432 100644 --- a/apps/meteor/client/views/room/MessageList/hooks/useMessageBody.tsx +++ b/apps/meteor/client/views/room/MessageList/hooks/useMessageBody.tsx @@ -31,11 +31,7 @@ export const useMessageBody = (message: IMessage | undefined): string | Root => } if (message.attachments) { - const attachment = message.attachments.find((attachment) => attachment.title || attachment.description); - - if (attachment?.description) { - return attachment.description; - } + const attachment = message.attachments.find((attachment) => attachment.title); if (attachment?.title) { return attachment.title; diff --git a/apps/meteor/client/views/room/contextualBar/ExportMessages/useDownloadExportMutation.ts b/apps/meteor/client/views/room/contextualBar/ExportMessages/useDownloadExportMutation.ts index f7b53352df5a1..291475075f4e4 100644 --- a/apps/meteor/client/views/room/contextualBar/ExportMessages/useDownloadExportMutation.ts +++ b/apps/meteor/client/views/room/contextualBar/ExportMessages/useDownloadExportMutation.ts @@ -39,7 +39,6 @@ export const useDownloadExportMutation = () => { ...('image_type' in attachment && { image_type: attachment.image_type }), ...('image_size' in attachment && { image_size: attachment.image_size }), ...('type' in attachment && { type: attachment.type }), - description: attachment.description, })) ?? [], }), ); diff --git a/apps/meteor/client/views/room/contextualBar/ExportMessages/useExportMessagesAsPDFMutation.tsx b/apps/meteor/client/views/room/contextualBar/ExportMessages/useExportMessagesAsPDFMutation.tsx index 716f7f3c8bd19..383388f0c316f 100644 --- a/apps/meteor/client/views/room/contextualBar/ExportMessages/useExportMessagesAsPDFMutation.tsx +++ b/apps/meteor/client/views/room/contextualBar/ExportMessages/useExportMessagesAsPDFMutation.tsx @@ -116,7 +116,6 @@ export const useExportMessagesAsPDFMutation = () => { {parseMessage(message)} {message.attachments?.map((attachment: MessageAttachmentDefault, index) => ( - {attachment.description && {attachment.description}} {attachment.image_url && } {attachment.title} diff --git a/apps/meteor/client/views/room/contextualBar/Threads/hooks/useNormalizedThreadTitleHtml.ts b/apps/meteor/client/views/room/contextualBar/Threads/hooks/useNormalizedThreadTitleHtml.ts index f391e6ad7bc75..874a95bfa9c01 100644 --- a/apps/meteor/client/views/room/contextualBar/Threads/hooks/useNormalizedThreadTitleHtml.ts +++ b/apps/meteor/client/views/room/contextualBar/Threads/hooks/useNormalizedThreadTitleHtml.ts @@ -33,11 +33,7 @@ export const useNormalizedThreadTitleHtml = (mainMessage: IThreadMainMessage) => } if (message.attachments) { - const attachment = message.attachments.find((attachment) => attachment.title || attachment.description); - - if (attachment?.description) { - return escapeHTML(attachment.description); - } + const attachment = message.attachments.find((attachment) => attachment.title); if (attachment?.title) { return escapeHTML(attachment.title); diff --git a/apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts b/apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts index b2480acff247d..d15ac6dbbc909 100644 --- a/apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts +++ b/apps/meteor/server/features/EmailInbox/EmailInbox_Outgoing.ts @@ -142,11 +142,7 @@ slashCommands.add({ return; } - const emailText = - message?.attachments - ?.map((a) => a.description) - .filter(Boolean) - .join('\n\n') || ''; + const emailText = message?.msg || ''; void sendEmail( inbox, diff --git a/apps/meteor/server/services/messages/hooks/BeforeSaveMarkdownParser.ts b/apps/meteor/server/services/messages/hooks/BeforeSaveMarkdownParser.ts index d311c84a688df..f4e26cdb97ee5 100644 --- a/apps/meteor/server/services/messages/hooks/BeforeSaveMarkdownParser.ts +++ b/apps/meteor/server/services/messages/hooks/BeforeSaveMarkdownParser.ts @@ -30,10 +30,6 @@ export class BeforeSaveMarkdownParser { if (message.msg) { message.md = parse(message.msg, config); } - - if (message.attachments?.[0]?.description) { - message.attachments[0].descriptionMd = parse(message.attachments[0].description, config); - } } catch (e) { console.error(e); // errors logged while the parser is at experimental stage } diff --git a/apps/meteor/tests/unit/server/services/messages/hooks/BeforeSaveJumpToMessage.tests.ts b/apps/meteor/tests/unit/server/services/messages/hooks/BeforeSaveJumpToMessage.tests.ts index 0ce7279e89b39..791404e4f1d9f 100644 --- a/apps/meteor/tests/unit/server/services/messages/hooks/BeforeSaveJumpToMessage.tests.ts +++ b/apps/meteor/tests/unit/server/services/messages/hooks/BeforeSaveJumpToMessage.tests.ts @@ -500,17 +500,6 @@ describe('Create attachments for message URLs', () => { image_size: 68016, type: 'file', description: 'chained 3 - file', - descriptionMd: [ - { - type: 'PARAGRAPH', - value: [ - { - type: 'PLAIN_TEXT', - value: 'chained 3 - file', - }, - ], - }, - ], }, ], }, diff --git a/apps/meteor/tests/unit/server/services/messages/hooks/BeforeSaveMarkdownParser.tests.ts b/apps/meteor/tests/unit/server/services/messages/hooks/BeforeSaveMarkdownParser.tests.ts index b633e085c5645..ae0f3ed284a7a 100644 --- a/apps/meteor/tests/unit/server/services/messages/hooks/BeforeSaveMarkdownParser.tests.ts +++ b/apps/meteor/tests/unit/server/services/messages/hooks/BeforeSaveMarkdownParser.tests.ts @@ -48,29 +48,4 @@ describe('Markdown parser', () => { expect(message).to.have.property('md'); }); - - it('should parse markdown on the first attachment only', async () => { - const markdownParser = new BeforeSaveMarkdownParser(true); - - const message = await markdownParser.parseMarkdown({ - message: createMessage('hey', { - attachments: [ - { - description: 'hey ho', - }, - { - description: 'lets go', - }, - ], - }), - config: {}, - }); - - expect(message).to.have.property('md'); - - const [attachment1, attachment2] = message.attachments || []; - - expect(attachment1).to.have.property('descriptionMd'); - expect(attachment2).to.not.have.property('descriptionMd'); - }); }); diff --git a/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts b/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts index fd9394aad3416..6532b1f505724 100644 --- a/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts +++ b/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts @@ -312,9 +312,7 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT } } - // When you send a file message, the things you type in the modal are not "msg", they're in "description" of the attachment - // So, we'll fetch the the msg, if empty, go for the first description on an attachment, if empty, empty string - const msg = message.msg || message.attachments.find((attachment) => attachment.description)?.description || ''; + const msg = message.msg || ''; // Remove nulls from final array messagesData.push({ msg, diff --git a/packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts b/packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts index f870f8cfc1ec7..4a151da95217c 100644 --- a/packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts +++ b/packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts @@ -6,7 +6,6 @@ export type MessageAttachmentBase = { ts?: Date; collapsed?: boolean; description?: string; - descriptionMd?: Root; text?: string; md?: Root; size?: number;