summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-09-28 20:36:07 +0200
committerRory& <root@rory.gay>2025-09-29 18:38:06 +0200
commitf8e4e8864f48dff5852af45e32c78adbdf9b07ca (patch)
tree5714b7ed64a33cf4912cf207e2994d13292693ed /src
parentUse default ID on file upload requests (diff)
downloadserver-ts-f8e4e8864f48dff5852af45e32c78adbdf9b07ca.tar.xz
Null coalescing for file id
Diffstat (limited to 'src')
-rw-r--r--src/api/routes/channels/#channel_id/attachments.ts5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/api/routes/channels/#channel_id/attachments.ts b/src/api/routes/channels/#channel_id/attachments.ts

index 0e0185d1..76e88bc2 100644 --- a/src/api/routes/channels/#channel_id/attachments.ts +++ b/src/api/routes/channels/#channel_id/attachments.ts
@@ -73,7 +73,6 @@ router.post( // validate IDs const seenIds: (string | undefined)[] = []; for (const file of payload.files) { - file.id ??= "0"; if (seenIds.includes(file.id)) { return res.status(400).json({ code: 400, @@ -86,12 +85,12 @@ router.post( const attachments = await Promise.all( payload.files.map(async (attachment) => { attachment.filename = attachment.filename.replaceAll(" ", "_").replace(/[^a-zA-Z0-9._]+/g, ""); - const uploadFilename = `${channel_id}/${batchId}/${attachment.id}/${attachment.filename}`; + const uploadFilename = `${channel_id}/${batchId}/${attachment.id ?? "0"}/${attachment.filename}`; const newAttachment = CloudAttachment.create({ user: user, channel: channel, uploadFilename: uploadFilename, - userAttachmentId: attachment.id, + userAttachmentId: attachment.id ?? "0", userFilename: attachment.filename, userFileSize: attachment.file_size, userIsClip: attachment.is_clip,