@@ -67,6 +67,7 @@ import {
6767 createSharedSlackChannelSchema ,
6868 parseOpportunitySchema ,
6969 opportunityMatchesQuerySchema ,
70+ gondulOpportunityPreviewResultSchema ,
7071} from '../common/schema/opportunities' ;
7172import { OpportunityKeyword } from '../entity/OpportunityKeyword' ;
7273import {
@@ -1284,11 +1285,22 @@ export const resolvers: IResolvers<unknown, BaseContext> = traceResolvers<
12841285 userIds = opportunity . flags . preview . userIds ;
12851286 totalCount = opportunity . flags . preview . totalCount ;
12861287 } else {
1288+ const opportunityContent : Record < string , unknown > = { } ;
1289+
1290+ // since this is json endpoint we need to make sure all keys are present
1291+ // even if empty, remove this when we move to protobuf service call
1292+ Object . keys ( new OpportunityContent ( ) ) . forEach ( ( key ) => {
1293+ const opportunityKey = key as keyof OpportunityContent ;
1294+
1295+ opportunityContent [ opportunityKey ] =
1296+ opportunity . content [ opportunityKey ] || { } ;
1297+ } ) ;
1298+
12871299 const validatedPayload = {
12881300 opportunity : {
12891301 title : opportunity . title ,
12901302 tldr : opportunity . tldr ,
1291- content : opportunity . content ,
1303+ content : opportunityContent ,
12921304 meta : opportunity . meta ,
12931305 location : opportunity . location ,
12941306 state : opportunity . state ,
@@ -1314,7 +1326,13 @@ export const resolvers: IResolvers<unknown, BaseContext> = traceResolvers<
13141326 if ( ! response . ok ) {
13151327 throw new Error ( 'Failed to fetch opportunity preview' ) ;
13161328 }
1317- return await response . json ( ) ;
1329+ const { user_ids, total_count } =
1330+ gondulOpportunityPreviewResultSchema . parse ( await response . json ( ) ) ;
1331+
1332+ return {
1333+ userIds : user_ids ,
1334+ totalCount : total_count ,
1335+ } ;
13181336 } ) ;
13191337
13201338 await ctx . con . getRepository ( OpportunityJob ) . update (
0 commit comments