From 3965c7040f93b575a97b818954d6e399f0179d7c Mon Sep 17 00:00:00 2001 From: OtavioStasiak Date: Wed, 1 Oct 2025 15:35:56 -0300 Subject: [PATCH 1/2] fix: quote image not loading --- .../message/Components/Attachments/Quote.tsx | 2 +- .../message/hooks/useMediaAutoDownload.tsx | 22 ++++++++++++++++++- .../methods/helpers/formatAttachmentUrl.ts | 12 +++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/app/containers/message/Components/Attachments/Quote.tsx b/app/containers/message/Components/Attachments/Quote.tsx index 16c77bd61b4..f7be8bdc872 100644 --- a/app/containers/message/Components/Attachments/Quote.tsx +++ b/app/containers/message/Components/Attachments/Quote.tsx @@ -11,7 +11,7 @@ import { getMessageFromAttachment } from '../../utils'; const isQuoteAttachment = (file?: IAttachment): boolean => { if (!file) return false; - if (file.image_url || file.audio_url || file.video_url || file.collapsed) { + if (!file.color && !file.text && (file.image_url || file.audio_url || file.video_url || file.collapsed)) { return false; } diff --git a/app/containers/message/hooks/useMediaAutoDownload.tsx b/app/containers/message/hooks/useMediaAutoDownload.tsx index f2e556feca4..06afbf5ccc7 100644 --- a/app/containers/message/hooks/useMediaAutoDownload.tsx +++ b/app/containers/message/hooks/useMediaAutoDownload.tsx @@ -35,6 +35,19 @@ const getFileProperty = (file: IAttachment, fileType: MediaTypes, property: 'url } }; +const getOriginalURL = (file: IAttachment): string | null => { + if (file.image_url) { + return file.image_url; + } + if (file.video_url) { + return file.video_url; + } + if (file.audio_url) { + return file.audio_url; + } + return null; +}; + export const useMediaAutoDownload = ({ file, author, @@ -48,7 +61,14 @@ export const useMediaAutoDownload = ({ const { id, baseUrl, user } = useContext(MessageContext); const [status, setStatus] = useState('to-download'); const [currentFile, setCurrentFile] = useFile(file, id); - const url = formatAttachmentUrl(file.title_link || getFileProperty(currentFile, fileType, 'url'), user.id, user.token, baseUrl); + const originalUrl = getOriginalURL(file); + const url = formatAttachmentUrl( + file.title_link || getFileProperty(currentFile, fileType, 'url'), + user.id, + user.token, + baseUrl, + originalUrl + ); const isEncrypted = currentFile.e2e === 'pending'; useEffect(() => { diff --git a/app/lib/methods/helpers/formatAttachmentUrl.ts b/app/lib/methods/helpers/formatAttachmentUrl.ts index 14de73785e9..a4f47b0cc35 100644 --- a/app/lib/methods/helpers/formatAttachmentUrl.ts +++ b/app/lib/methods/helpers/formatAttachmentUrl.ts @@ -10,13 +10,23 @@ function setParamInUrl({ url, token, userId }: { url: string; token: string; use return urlObj.toString(); } -export const formatAttachmentUrl = (attachmentUrl: string | undefined, userId: string, token: string, server: string): string => { +export const formatAttachmentUrl = ( + attachmentUrl: string | undefined, + userId: string, + token: string, + server: string, + _originalUrl?: string | null +): string => { const protectFiles = store.getState().settings.FileUpload_ProtectFiles; if ((attachmentUrl && isImageBase64(attachmentUrl)) || attachmentUrl?.startsWith('file://')) { return attachmentUrl; } if (attachmentUrl && attachmentUrl.startsWith('http')) { + if (_originalUrl && !_originalUrl.startsWith(server)) { + return _originalUrl; + } + if (attachmentUrl.includes('rc_token')) { return encodeURI(attachmentUrl); } From 5bb26804a8a15b8eaf6dd9f02291d5a162239e71 Mon Sep 17 00:00:00 2001 From: OtavioStasiak Date: Fri, 3 Oct 2025 17:09:25 -0300 Subject: [PATCH 2/2] chore: snapshot tests --- app/containers/message/Message.stories.tsx | 14 + .../__snapshots__/Message.test.tsx.snap | 1296 +++++++++++++++++ 2 files changed, 1310 insertions(+) diff --git a/app/containers/message/Message.stories.tsx b/app/containers/message/Message.stories.tsx index 234dfef1a57..8c1b25b3cf4 100644 --- a/app/containers/message/Message.stories.tsx +++ b/app/containers/message/Message.stories.tsx @@ -2017,3 +2017,17 @@ export const CollapsedAttachmentsLargeFont = () => ( ); + +const attachmentWithTextAndLink = [ + { + title: 'Rocket.Chat', + title_link: 'https://rocket.chat', + text: 'Rocket.Chat, the best open source chat', + image_url: 'https://rc.jena.de/images/integration-attachment-example.png', + color: '#764FA5' + } +]; + +export const AttachmentWithTextAndLink = () => ; + +export const AttachmentWithTextAndLinkLargeFont = () => ; diff --git a/app/containers/message/__snapshots__/Message.test.tsx.snap b/app/containers/message/__snapshots__/Message.test.tsx.snap index 2740ca0f68f..75c4b87fb50 100644 --- a/app/containers/message/__snapshots__/Message.test.tsx.snap +++ b/app/containers/message/__snapshots__/Message.test.tsx.snap @@ -710,6 +710,1302 @@ exports[`Story Snapshots: ArchivedLargeFont should match snapshot 1`] = ` `; +exports[`Story Snapshots: AttachmentWithTextAndLink should match snapshot 1`] = ` + + + + + + + + + + + + + + + + + + diego.mello + + + 10:00 AM + + + + + + + + + + + + + Rocket.Chat + + + + + + + Rocket.Chat + + + , the best open source chat + + + + + + + + + + + + + + + + +  + + + + + + + + + + + + + + +`; + +exports[`Story Snapshots: AttachmentWithTextAndLinkLargeFont should match snapshot 1`] = ` + + + + + + + + + + + + + + + + + + diego.mello + + + + + + 10:00 AM + + + + + + + + + + Rocket.Chat + + + + + + + Rocket.Chat + + + , the best open source chat + + + + + + + + + + + + + + + + +  + + + + + + + + + + + + + + +`; + exports[`Story Snapshots: Avatar should match snapshot 1`] = `