fix: Archived documents should not be returned from documents.list
closes #1575
This commit is contained in:
@@ -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 };
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user