fix: Policies missing on documents.viewed endpoint

This commit is contained in:
Tom Moor
2021-08-03 20:02:11 -07:00
parent dad21b2186
commit f2f550e1d2
2 changed files with 11 additions and 2 deletions

View File

@@ -310,9 +310,10 @@ router.post("documents.viewed", auth(), pagination(), async (ctx) => {
const user = ctx.state.user;
const collectionIds = await user.collectionIds();
const userId = user.id;
const views = await View.findAll({
where: { userId: user.id },
where: { userId },
order: [[sort, direction]],
include: [
{
@@ -325,9 +326,16 @@ router.post("documents.viewed", auth(), pagination(), async (ctx) => {
{
model: Star,
as: "starred",
where: { userId: user.id },
where: { userId },
separate: true,
required: false,
},
{
model: Collection.scope({
method: ["withMembership", userId],
}),
as: "collection",
},
],
},
],

View File

@@ -1349,6 +1349,7 @@ describe("#documents.viewed", () => {
expect(res.status).toEqual(200);
expect(body.data.length).toEqual(1);
expect(body.data[0].id).toEqual(document.id);
expect(body.policies[0].abilities.update).toEqual(true);
});
it("should not return recently viewed but deleted documents", async () => {