mirror of
https://github.com/outline/outline.git
synced 2026-11-28 16:19:46 +03:00
fix: Apply collection filter to document-only events
This commit is contained in:
2 files changed
+33
No files matched your search
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user