diff --git a/server/routes/api/events/events.test.ts b/server/routes/api/events/events.test.ts index 1e86201b0c..52dc9bf330 100644 --- a/server/routes/api/events/events.test.ts +++ b/server/routes/api/events/events.test.ts @@ -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); } }); diff --git a/server/routes/api/events/events.ts b/server/routes/api/events/events.ts index 885faaef3f..e3657d8122 100644 --- a/server/routes/api/events/events.ts +++ b/server/routes/api/events/events.ts @@ -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,