@@ -1343,6 +1343,13 @@ async function searchChallenges(currentUser, criteria) {
13431343 }
13441344 } ) ;
13451345
1346+ // handle projectIds (array of project IDs, applied as IN filter)
1347+ if ( Array . isArray ( criteria . projectIds ) && criteria . projectIds . length > 0 ) {
1348+ prismaFilter . where . AND . push ( {
1349+ projectId : { in : criteria . projectIds } ,
1350+ } ) ;
1351+ }
1352+
13461353 // handle status
13471354 if ( ! _ . isNil ( criteria . status ) ) {
13481355 prismaFilter . where . AND . push ( {
@@ -1649,6 +1656,18 @@ async function searchChallenges(currentUser, criteria) {
16491656 currentUser ,
16501657 ) ;
16511658 }
1659+ // When filtering by multiple project IDs, treat as having project manager access
1660+ // (the caller is expected to pass only project IDs the user has access to)
1661+ if (
1662+ ! hasProjectManagerAccessForSearch &&
1663+ currentUser &&
1664+ ! _hasAdminRole &&
1665+ ! _isMachineToken &&
1666+ Array . isArray ( criteria . projectIds ) &&
1667+ criteria . projectIds . length > 0
1668+ ) {
1669+ hasProjectManagerAccessForSearch = true ;
1670+ }
16521671
16531672 let groupsToFilter = [ ] ;
16541673 let accessibleGroups = [ ] ;
@@ -2071,6 +2090,7 @@ searchChallenges.schema = {
20712090 tags : Joi . array ( ) . items ( Joi . string ( ) ) ,
20722091 includeAllTags : Joi . boolean ( ) . default ( true ) ,
20732092 projectId : Joi . number ( ) . integer ( ) . positive ( ) ,
2093+ projectIds : Joi . array ( ) . items ( Joi . number ( ) . integer ( ) . positive ( ) ) ,
20742094 forumId : Joi . number ( ) . integer ( ) ,
20752095 legacyId : Joi . number ( ) . integer ( ) . positive ( ) ,
20762096 status : Joi . string ( )
0 commit comments