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/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`] = `
{
+ 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);
}