Skip to content

Commit f10526b

Browse files
committed
review
1 parent 0a26692 commit f10526b

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

ee/packages/abac/src/pdp/VirtruPDP.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,23 +357,22 @@ export class VirtruPDP implements IPolicyDecisionPoint {
357357
return [];
358358
}
359359

360-
const abacRooms = await Rooms.findPrivateRoomsByIdsWithAbacAttributes(roomIds, {
360+
const abacRoomCursor = Rooms.findPrivateRoomsByIdsWithAbacAttributes(roomIds, {
361361
projection: { _id: 1, abacAttributes: 1 },
362-
}).toArray();
362+
});
363363

364-
const abacRoomById = Object.fromEntries(abacRooms.map((room) => [room._id, room]));
364+
const abacRoomById = new Map<string, IRoom>();
365+
for await (const room of abacRoomCursor) {
366+
abacRoomById.set(room._id, room);
367+
}
365368

366369
const entries = users
367370
.map((user) => {
368-
const rooms = (user.__rooms ?? []).map((rid) => abacRoomById[rid]).filter(Boolean);
371+
const rooms = (user.__rooms ?? []).map((rid) => abacRoomById.get(rid)).filter(isTruthy);
369372
return rooms.length ? { user, rooms } : null;
370373
})
371374
.filter(isTruthy);
372375

373-
if (!entries.length) {
374-
return [];
375-
}
376-
377376
return this.evaluateUserRooms(entries);
378377
}
379378

0 commit comments

Comments
 (0)