From c92e5d03a7f1db4ef72474797842dcdc4ba75dbd Mon Sep 17 00:00:00 2001 From: Hampus Date: Tue, 22 Sep 2026 21:18:35 +0200 Subject: [PATCH] fix(api): accept any image or video attachment as embed media (#2901) --- .../message/MessageEmbedAttachmentResolver.ts | 13 +++++---- .../EmbedAttachmentUrlResolution.test.ts | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/fluxer_api/src/api/channel/services/message/MessageEmbedAttachmentResolver.ts b/fluxer_api/src/api/channel/services/message/MessageEmbedAttachmentResolver.ts index 628113cec..7e0efe454 100644 --- a/fluxer_api/src/api/channel/services/message/MessageEmbedAttachmentResolver.ts +++ b/fluxer_api/src/api/channel/services/message/MessageEmbedAttachmentResolver.ts @@ -3,7 +3,7 @@ import type {AttachmentID, ChannelID} from '@app/api/BrandedTypes'; import type {AttachmentRequestData} from '@app/api/channel/AttachmentDTOs'; import type {RichEmbedMediaWithMetadata} from '@app/api/channel/EmbedTypes'; -import {makeAttachmentCdnUrl} from '@app/api/channel/services/message/MessageHelpers'; +import {getContentType, makeAttachmentCdnUrl} from '@app/api/channel/services/message/MessageHelpers'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; @@ -26,7 +26,10 @@ interface RichEmbedRequestWithMetadata extends Omit { expect(json.embeds).toHaveLength(1); expect(json.embeds![0].image?.url).not.toContain('attachment://'); }); + it('should accept image and video attachments beyond the legacy image extensions', async () => { + const account = await createTestAccount(harness); + const guild = await createGuild(harness, account.token, 'Media Type Guild'); + const channel = await createChannel(harness, account.token, guild.id, 'test-channel'); + const channelId = guild.system_channel_id ?? channel.id; + const payload = { + content: 'Test with jxl and mp4 embed media', + attachments: [ + {id: 0, filename: 'photo.jxl'}, + {id: 1, filename: 'clip.mp4'}, + ], + embeds: [ + { + title: 'Media Embed', + image: {url: 'attachment://clip.mp4'}, + thumbnail: {url: 'attachment://photo.jxl'}, + }, + ], + }; + const {response, json} = await sendMessageWithAttachments(harness, account.token, channelId, payload, [ + {index: 0, filename: 'photo.jxl', data: Buffer.from('jxl bytes')}, + {index: 1, filename: 'clip.mp4', data: Buffer.from('mp4 bytes')}, + ]); + expect(response.status).toBe(200); + expect(json.embeds).toHaveLength(1); + expect(json.embeds![0].image?.url).not.toContain('attachment://'); + expect(json.embeds![0].thumbnail?.url).not.toContain('attachment://'); + }); }); describe('Multiple Embeds and Files', () => { it('should handle multiple embeds with different URL types', async () => {