fix: Apply collection filter to document-only events

This commit is contained in:
Tom Moor committed 2026-11-26 19:34:24 -05:00
1 parent 4b430243c7
commit 144d1ca709
2 files changed
+33

No files matched your search

+13
View File
@@ -501,6 +501,18 @@ describe("#events.list", () => {
teamId: user.teamId,
actorId: user.id,
});
const document = await buildDocument({
userId: user.id,
teamId: user.teamId,
collectionId: collection.id,
});
const revisionEvent = await buildEvent({
name: "revisions.create",
documentId: document.id,
collectionId: null,
teamId: user.teamId,
actorId: user.id,
});
for (const auditLog of [false, true]) {
const res = await server.post("/api/events.list", admin, {
@@ -511,6 +523,7 @@ describe("#events.list", () => {
const eventIds = body.data.map((e: { id: string }) => e.id);
expect(eventIds).toContain(ownEvent.id);
expect(eventIds).not.toContain(otherEvent.id);
expect(eventIds).not.toContain(revisionEvent.id);
}
});
+20
View File
@@ -91,6 +91,12 @@ router.post(
{ "$collection.ownerId$": user.id },
],
},
{
[Op.or]: [
{ "$document.collection.ownerId$": null },
{ "$document.collection.ownerId$": user.id },
],
},
],
},
order: [[sort, direction]],
@@ -106,6 +112,20 @@ router.post(
attributes: [],
paranoid: false,
},
{
model: Document.unscoped(),
as: "document",
attributes: [],
paranoid: false,
include: [
{
model: Collection.unscoped(),
as: "collection",
attributes: [],
paranoid: false,
},
],
},
],
offset: ctx.state.pagination.offset,
limit: ctx.state.pagination.limit,