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",
},
],
},
],