Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/workers/notifications/candidateOpportunityMatchNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'> =
{
Expand All @@ -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,
Expand Down
23 changes: 10 additions & 13 deletions src/workers/notifications/warmIntroNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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()
Expand All @@ -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;

Expand Down
11 changes: 11 additions & 0 deletions src/workers/opportunity/storeCandidateApplicationScore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'> =
{
Expand All @@ -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,
Expand Down
12 changes: 11 additions & 1 deletion src/workers/opportunity/storeCandidateOpportunityMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'> =
{
Expand All @@ -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,
Expand Down
Loading