Skip to content

Commit b28f304

Browse files
committed
šŸ› (share) the search for accesses was not including members not being project managers
1 parent 156f73f commit b28f304

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

ā€Žserver/api/helpers/users/search-many.jsā€Ž

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,30 @@ module.exports = {
5454
userIdsInSameBoards = sameBoardMemberships.map((bm) => bm.userId);
5555
}
5656

57-
// Find all users in the same projects
57+
// Find all users in the same projects (both managers and board members)
5858
let userIdsInSameProjects = [];
5959
if (currentUserProjectIds.length > 0) {
6060
const sameProjectManagements = await ProjectManager.find({
6161
projectId: currentUserProjectIds,
6262
});
63-
userIdsInSameProjects = sameProjectManagements.map((pm) => pm.userId);
63+
64+
const boardsInProjects = await Board.find({
65+
projectId: currentUserProjectIds,
66+
}).select(['id']);
67+
const boardIdsInProjects = boardsInProjects.map((b) => b.id);
68+
69+
let userIdsInProjectBoards = [];
70+
if (boardIdsInProjects.length > 0) {
71+
const projectBoardMemberships = await BoardMembership.find({
72+
boardId: boardIdsInProjects,
73+
});
74+
userIdsInProjectBoards = projectBoardMemberships.map((bm) => bm.userId);
75+
}
76+
77+
userIdsInSameProjects = [
78+
...sameProjectManagements.map((pm) => pm.userId),
79+
...userIdsInProjectBoards,
80+
];
6481
}
6582

6683
// Combine all user IDs from shared contexts (excluding needed ones)

0 commit comments

Comments
Ā (0)