File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -246,6 +246,11 @@ jest.mock('../../../src/temporal/notifications/utils', () => ({
246246 cancelEntityReminderWorkflow : jest . fn ( ) ,
247247} ) ) ;
248248
249+ jest . mock ( '../../../src/cio' , ( ) => ( {
250+ ...( jest . requireActual ( '../../../src/cio' ) as Record < string , unknown > ) ,
251+ identifyUserOpportunities : jest . fn ( ) ,
252+ } ) ) ;
253+
249254let con : DataSource ;
250255
251256beforeAll ( async ( ) => {
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ import type { UserCompany } from './entity/UserCompany';
4646import type { Company } from './entity/Company' ;
4747import { DataSource , In } from 'typeorm' ;
4848import { logger } from './logger' ;
49+ import { OpportunityMatch } from './entity/OpportunityMatch' ;
50+ import { OpportunityMatchStatus } from './entity/opportunities/types' ;
4951
5052export const cio = new TrackClient (
5153 process . env . CIO_SITE_ID ,
@@ -149,6 +151,29 @@ export async function identifyUserStreak({
149151 }
150152}
151153
154+ export const identifyUserOpportunities = async ( {
155+ cio,
156+ con,
157+ userId,
158+ } : {
159+ cio : TrackClient ;
160+ con : ConnectionManager ;
161+ userId : string ;
162+ } ) : Promise < void > => {
163+ const opportunities = await con . getRepository ( OpportunityMatch ) . find ( {
164+ where : {
165+ userId,
166+ status : OpportunityMatchStatus . Pending ,
167+ } ,
168+ select : [ 'opportunityId' ] ,
169+ } ) ;
170+ await cio . identify ( userId , {
171+ opportunities : opportunities . map (
172+ ( opportunity ) => opportunity . opportunityId ,
173+ ) ,
174+ } ) ;
175+ } ;
176+
152177export const generateIdentifyObject = async (
153178 con : ConnectionManager ,
154179 user : ChangeObject < User > ,
Original file line number Diff line number Diff line change @@ -162,6 +162,7 @@ import { PollPost } from '../../entity/posts/PollPost';
162162import { UserExperienceWork } from '../../entity/user/experiences/UserExperienceWork' ;
163163import { UserExperience } from '../../entity/user/experiences/UserExperience' ;
164164import { UserExperienceType } from '../../entity/user/experiences/types' ;
165+ import { cio , identifyUserOpportunities } from '../../cio' ;
165166
166167const isFreeformPostLongEnough = (
167168 freeform : ChangeMessage < FreeformPost > ,
@@ -1292,6 +1293,11 @@ const onOpportunityMatchChange = async (
12921293 logger : FastifyBaseLogger ,
12931294 data : ChangeMessage < OpportunityMatch > ,
12941295) => {
1296+ await identifyUserOpportunities ( {
1297+ con,
1298+ cio,
1299+ userId : data . payload . after ?. userId ?? data . payload . before ?. userId ?? '' ,
1300+ } ) ;
12951301 if ( data . payload . op === 'u' ) {
12961302 if (
12971303 data . payload . after ?. status === OpportunityMatchStatus . CandidateAccepted &&
You can’t perform that action at this time.
0 commit comments