fix: Policies missing on documents.viewed endpoint
This commit is contained in:
@@ -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",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user