diff --git a/__tests__/workers/candidateAcceptedOpportunitySlack.ts b/__tests__/workers/candidateAcceptedOpportunitySlack.ts index c0ba817943..1bfb02a13f 100644 --- a/__tests__/workers/candidateAcceptedOpportunitySlack.ts +++ b/__tests__/workers/candidateAcceptedOpportunitySlack.ts @@ -81,6 +81,10 @@ describe('candidateAcceptedOpportunitySlack worker', () => { title: 'Opportunity ID', value: '550e8400-e29b-41d4-a716-446655440001', }, + { + title: 'Company name', + value: 'Daily Dev Inc', + }, ], color: '#1DDC6F', }, @@ -131,6 +135,10 @@ describe('candidateAcceptedOpportunitySlack worker', () => { title: 'Opportunity ID', value: '550e8400-e29b-41d4-a716-446655440001', }, + { + title: 'Company name', + value: 'Daily Dev Inc', + }, ], color: '#1DDC6F', }, @@ -197,6 +205,10 @@ describe('candidateAcceptedOpportunitySlack worker', () => { title: 'Opportunity ID', value: '550e8400-e29b-41d4-a716-446655440002', }, + { + title: 'Company name', + value: 'Daily Dev Inc', + }, ], color: '#1DDC6F', }, diff --git a/src/workers/candidateAcceptedOpportunitySlack.ts b/src/workers/candidateAcceptedOpportunitySlack.ts index d392febe00..a1b42ab3ce 100644 --- a/src/workers/candidateAcceptedOpportunitySlack.ts +++ b/src/workers/candidateAcceptedOpportunitySlack.ts @@ -1,5 +1,6 @@ import { TypedWorker } from './worker'; import { OpportunityMatch } from '../entity/OpportunityMatch'; +import { OpportunityJob } from '../entity/opportunities/OpportunityJob'; import { webhooks } from '../common'; import { CandidateAcceptedOpportunityMessage } from '@dailydotdev/schema'; @@ -30,6 +31,12 @@ const worker: TypedWorker<'api.v1.candidate-accepted-opportunity'> = { const opportunity = await match.opportunity; const user = await match.user; + let organizationName = 'N/A'; + if (opportunity instanceof OpportunityJob && opportunity.organizationId) { + const organization = await opportunity.organization; + organizationName = organization?.name || 'N/A'; + } + await webhooks.recruiter.send({ text: 'Candidate accepted opportunity!', attachments: [ @@ -49,6 +56,10 @@ const worker: TypedWorker<'api.v1.candidate-accepted-opportunity'> = { title: 'Opportunity ID', value: opportunityId, }, + { + title: 'Company name', + value: organizationName, + }, ], color: '#1DDC6F', },