diff --git a/src/workers/notifications/candidateOpportunityMatchNotification.ts b/src/workers/notifications/candidateOpportunityMatchNotification.ts index e5667d449..fbb27b0b4 100644 --- a/src/workers/notifications/candidateOpportunityMatchNotification.ts +++ b/src/workers/notifications/candidateOpportunityMatchNotification.ts @@ -2,6 +2,7 @@ import { NotificationType } from '../../notifications/common'; import { TypedNotificationWorker } from '../worker'; import { TypeORMQueryFailedError } from '../../errors'; import { MatchedCandidate } from '@dailydotdev/schema'; +import { User } from '../../entity'; const candidateOpportunityMatchNotification: TypedNotificationWorker<'gondul.v1.candidate-opportunity-match'> = { @@ -17,6 +18,15 @@ const candidateOpportunityMatchNotification: TypedNotificationWorker<'gondul.v1. return; } + const user = await con.getRepository(User).findOneBy({ id: userId }); + if (!user) { + logger.error( + { opportunityId, userId }, + 'candidateOpportunityMatchNotification: User not found', + ); + return; + } + return [ { type: NotificationType.NewOpportunityMatch, diff --git a/src/workers/notifications/warmIntroNotification.ts b/src/workers/notifications/warmIntroNotification.ts index ae1098347..3366d05ba 100644 --- a/src/workers/notifications/warmIntroNotification.ts +++ b/src/workers/notifications/warmIntroNotification.ts @@ -4,7 +4,7 @@ import { logger } from '../../logger'; import { OpportunityJob } from '../../entity/opportunities/OpportunityJob'; import { OpportunityUserType } from '../../entity/opportunities/types'; import { WarmIntro } from '@dailydotdev/schema'; -import { Feature, FeatureType } from '../../entity'; +import { User } from '../../entity'; import { OpportunityMatch } from '../../entity/OpportunityMatch'; import { markdown } from '../../common/markdown'; @@ -27,6 +27,15 @@ export const warmIntroNotification: TypedNotificationWorker<'gondul.v1.warm-intr return; } + const user = await con.getRepository(User).findOneBy({ id: userId }); + if (!user) { + logger.error( + { opportunityId, userId, opportunity }, + 'warmIntroNotification: User not found', + ); + return; + } + await con .getRepository(OpportunityMatch) .createQueryBuilder() @@ -43,18 +52,6 @@ export const warmIntroNotification: TypedNotificationWorker<'gondul.v1.warm-intr ) .execute(); - // TODO: Temporary until we happy to launch - const isTeamMember = await con.getRepository(Feature).exists({ - where: { - userId, - feature: FeatureType.Team, - value: 1, - }, - }); - if (!isTeamMember) { - return; - } - const organization = await opportunity.organization; const users = await opportunity.users; diff --git a/src/workers/opportunity/storeCandidateApplicationScore.ts b/src/workers/opportunity/storeCandidateApplicationScore.ts index d621f7230..9e831659e 100644 --- a/src/workers/opportunity/storeCandidateApplicationScore.ts +++ b/src/workers/opportunity/storeCandidateApplicationScore.ts @@ -2,6 +2,8 @@ import { TypedWorker } from '../worker'; import { ApplicationScored } from '@dailydotdev/schema'; import { OpportunityMatch } from '../../entity/OpportunityMatch'; import { applicationScoreSchema } from '../../common/schema/opportunities'; +import { User } from '../../entity'; +import { logger } from '../../logger'; export const storeCandidateApplicationScore: TypedWorker<'gondul.v1.candidate-application-scored'> = { @@ -14,6 +16,15 @@ export const storeCandidateApplicationScore: TypedWorker<'gondul.v1.candidate-ap ); } + const user = await con.getRepository(User).findOneBy({ id: userId }); + if (!user) { + logger.error( + { opportunityId, userId }, + 'storeCandidateApplicationScore: User not found', + ); + return; + } + const applicationRank = applicationScoreSchema.parse({ score, description, diff --git a/src/workers/opportunity/storeCandidateOpportunityMatch.ts b/src/workers/opportunity/storeCandidateOpportunityMatch.ts index 72609fe3e..cccc8a4e6 100644 --- a/src/workers/opportunity/storeCandidateOpportunityMatch.ts +++ b/src/workers/opportunity/storeCandidateOpportunityMatch.ts @@ -2,8 +2,9 @@ import { TypedWorker } from '../worker'; import { MatchedCandidate } from '@dailydotdev/schema'; import { OpportunityMatch } from '../../entity/OpportunityMatch'; import { opportunityMatchDescriptionSchema } from '../../common/schema/opportunities'; -import { Alerts } from '../../entity'; +import { Alerts, User } from '../../entity'; import { IsNull } from 'typeorm'; +import { logger } from '../../logger'; export const storeCandidateOpportunityMatch: TypedWorker<'gondul.v1.candidate-opportunity-match'> = { @@ -17,6 +18,15 @@ export const storeCandidateOpportunityMatch: TypedWorker<'gondul.v1.candidate-op ); } + const user = await con.getRepository(User).findOneBy({ id: userId }); + if (!user) { + logger.error( + { opportunityId, userId }, + 'storeCandidateOpportunityMatch: User not found', + ); + return; + } + const description = opportunityMatchDescriptionSchema.parse({ reasoning, reasoningShort,