From db765d8ff0423ec9eea9b624973895569ddff558 Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 23 Sep 2025 23:25:08 +0200 Subject: [PATCH] Update message schema to handle cloud attachments --- src/api/routes/channels/#channel_id/attachments.ts | 1 + src/util/schemas/MessageCreateSchema.ts | 10 +++------- .../responses/UploadAttachmentResponseSchema.ts | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/api/routes/channels/#channel_id/attachments.ts b/src/api/routes/channels/#channel_id/attachments.ts index d0297dce..555eb0ad 100644 --- a/src/api/routes/channels/#channel_id/attachments.ts +++ b/src/api/routes/channels/#channel_id/attachments.ts @@ -93,6 +93,7 @@ router.post( id: a.userAttachmentId, upload_filename: a.uploadFilename, upload_url: `${cdnUrl}/attachments/${a.uploadFilename}`, + original_content_type: a.userOriginalContentType } })} as UploadAttachmentResponseSchema); }, diff --git a/src/util/schemas/MessageCreateSchema.ts b/src/util/schemas/MessageCreateSchema.ts index 2538d39e..2bd6ccf5 100644 --- a/src/util/schemas/MessageCreateSchema.ts +++ b/src/util/schemas/MessageCreateSchema.ts @@ -16,12 +16,8 @@ along with this program. If not, see . */ -import { - ActionRowComponent, - Embed, - PollAnswer, - PollMedia, -} from "@spacebar/util"; +import { ActionRowComponent, Embed, PollAnswer, PollMedia, UploadAttachmentResponse } from "@spacebar/util"; +import { CloudAttachment } from "../entities/CloudAttachment"; export type MessageCreateAttachment = { id: string; @@ -57,7 +53,7 @@ export interface MessageCreateSchema { TODO: we should create an interface for attachments TODO: OpenWAAO<-->attachment-style metadata conversion **/ - attachments?: MessageCreateAttachment[]; + attachments?: (MessageCreateAttachment | UploadAttachmentResponse)[]; sticker_ids?: string[]; components?: ActionRowComponent[]; // TODO: Fix TypeScript errors in src\api\util\handlers\Message.ts once this is enabled diff --git a/src/util/schemas/responses/UploadAttachmentResponseSchema.ts b/src/util/schemas/responses/UploadAttachmentResponseSchema.ts index 322137da..eab5f22e 100644 --- a/src/util/schemas/responses/UploadAttachmentResponseSchema.ts +++ b/src/util/schemas/responses/UploadAttachmentResponseSchema.ts @@ -25,4 +25,5 @@ export interface UploadAttachmentResponse { id?: string; upload_url: string; upload_filename: string; + original_content_type?: string; }