diff --git a/server/api/documents.js b/server/api/documents.js index 44e54b2a2..749f7082f 100644 --- a/server/api/documents.js +++ b/server/api/documents.js @@ -46,7 +46,12 @@ router.post("documents.list", auth(), pagination(), async (ctx) => { // always filter by the current team const user = ctx.state.user; - let where = { teamId: user.teamId }; + let where = { + teamId: user.teamId, + archivedAt: { + [Op.eq]: null, + }, + }; if (template) { where = { ...where, template: true }; diff --git a/server/api/documents.test.js b/server/api/documents.test.js index 176215d8e..ff20f03cc 100644 --- a/server/api/documents.test.js +++ b/server/api/documents.test.js @@ -430,6 +430,20 @@ describe("#documents.list", () => { expect(body.data.length).toEqual(0); }); + it("should not return archived documents", async () => { + const { user, document } = await seed(); + document.archivedAt = new Date(); + await document.save(); + + const res = await server.post("/api/documents.list", { + body: { token: user.getJwtToken() }, + }); + const body = await res.json(); + + expect(res.status).toEqual(200); + expect(body.data.length).toEqual(0); + }); + it("should not return documents in private collections not a member of", async () => { const { user, collection } = await seed(); collection.private = true;