@@ -239,6 +239,9 @@ const roomRequestRoutes: FastifyPluginAsync = async (fastify, _options) => {
239239 } ) ;
240240 }
241241 const items = response . Items . map ( ( x ) => {
242+ if ( ! request . query . select . includes ( "status" ) ) {
243+ return unmarshall ( x ) ;
244+ }
242245 const item = unmarshall ( x ) as {
243246 host : string ;
244247 title : string ;
@@ -418,20 +421,29 @@ const roomRequestRoutes: FastifyPluginAsync = async (fastify, _options) => {
418421 example : "sp25" ,
419422 } ) ,
420423 } ) ,
424+ querystring : z . object (
425+ getDefaultFilteringQuerystring ( {
426+ defaultSelect : [ "requestId" , "title" ] ,
427+ } ) ,
428+ ) ,
421429 } ) ,
422430 ) ,
423431 onRequest : fastify . authorizeFromSchema ,
424432 } ,
425433 async ( request , reply ) => {
426434 const requestId = request . params . requestId ;
427435 const semesterId = request . params . semesterId ;
436+ const { ProjectionExpression, ExpressionAttributeNames } =
437+ generateProjectionParams ( { userFields : request . query . select } ) ;
428438 let command ;
429439 if ( request . userRoles ?. has ( AppRoles . BYPASS_OBJECT_LEVEL_AUTH ) ) {
430440 command = new QueryCommand ( {
431441 TableName : genericConfig . RoomRequestsTableName ,
432442 IndexName : "RequestIdIndex" ,
433443 KeyConditionExpression : "requestId = :requestId" ,
434444 FilterExpression : "semesterId = :semesterId" ,
445+ ProjectionExpression,
446+ ExpressionAttributeNames,
435447 ExpressionAttributeValues : {
436448 ":requestId" : { S : requestId } ,
437449 ":semesterId" : { S : semesterId } ,
@@ -441,6 +453,7 @@ const roomRequestRoutes: FastifyPluginAsync = async (fastify, _options) => {
441453 } else {
442454 command = new QueryCommand ( {
443455 TableName : genericConfig . RoomRequestsTableName ,
456+ ProjectionExpression,
444457 KeyConditionExpression :
445458 "semesterId = :semesterId AND #userIdRequestId = :userRequestId" ,
446459 ExpressionAttributeValues : {
@@ -449,6 +462,7 @@ const roomRequestRoutes: FastifyPluginAsync = async (fastify, _options) => {
449462 } ,
450463 ExpressionAttributeNames : {
451464 "#userIdRequestId" : "userId#requestId" ,
465+ ...ExpressionAttributeNames ,
452466 } ,
453467 Limit : 1 ,
454468 } ) ;
0 commit comments