From 89a1da7ee69e84070d7c619087b1a424f17c8d11 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 8 Sep 2026 11:04:25 -0400 Subject: [PATCH] fix: Allow viewers with collection write access to import documents (#13707) --- server/routes/api/attachments/attachments.test.ts | 10 ++++++++-- server/routes/api/attachments/attachments.ts | 3 --- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/routes/api/attachments/attachments.test.ts b/server/routes/api/attachments/attachments.test.ts index 15d50287c3..7d001f7327 100644 --- a/server/routes/api/attachments/attachments.test.ts +++ b/server/routes/api/attachments/attachments.test.ts @@ -258,7 +258,7 @@ describe("#attachments.create", () => { expect(attachment.expiresAt).toBeTruthy(); }); - it("should not allow viewer to upload using import preset", async () => { + it("should allow viewer to upload using import preset", async () => { const user = await buildViewer(); const res = await server.post("/api/attachments.create", user, { body: { @@ -268,7 +268,13 @@ describe("#attachments.create", () => { preset: AttachmentPreset.Import, }, }); - expect(res.status).toEqual(403); + expect(res.status).toEqual(200); + + const body = await res.json(); + const attachment = await Attachment.findByPk(body.data.attachment.id, { + rejectOnEmpty: true, + }); + expect(attachment.expiresAt).toBeTruthy(); }); it("should not allow attachment creation for other documents", async () => { diff --git a/server/routes/api/attachments/attachments.ts b/server/routes/api/attachments/attachments.ts index 8c952c2f5a..ac70e7729d 100644 --- a/server/routes/api/attachments/attachments.ts +++ b/server/routes/api/attachments/attachments.ts @@ -106,9 +106,6 @@ router.post( if (preset === AttachmentPreset.WorkspaceImport) { authorize(user, "createImport", user.team); } - if (preset === AttachmentPreset.Import) { - authorize(user, "createDocument", user.team); - } if (preset === AttachmentPreset.Emoji) { assertIn(contentType, AttachmentValidation.emojiContentTypes); }