Skip to content

Commit

Permalink
Created mailer method and using it in auth controller (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
DDZBX authored Nov 26, 2024
1 parent f4c761f commit dab413c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ export class AuthController {
throw new NotFoundException();
}

await this.authService.sendRefererCandidateHasVerifiedAccountMail(
updatedUser.referer,
updatedUser
);

return updatedUser.email;
}
}
10 changes: 10 additions & 0 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ export class AuthService {
return this.mailsService.sendVerificationMail(user, token);
}

async sendRefererCandidateHasVerifiedAccountMail(
referer: User,
candidate: User
) {
return this.mailsService.sendRefererCandidateHasVerifiedAccountMail(
referer,
candidate
);
}

async generateVerificationToken(user: User) {
return this.jwtService.sign(
{ sub: user.id },
Expand Down
1 change: 1 addition & 0 deletions src/external-services/mailjet/mailjet.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const MailjetTemplates = {
ONBOARDING_J1_BAO: 6129684,
ONBOARDING_J3_PROFILE_COMPLETION: 6129711,
REFERER_ONBOARDING_CONFIRMATION: 6324339,
REFERER_CANDIDATE_HAS_FINALIZED_ACCOUNT: 6482813,
REFERED_CANDIDATE_FINALIZE_ACCOUNT: 6324039,
ADMIN_NEW_REFERER_NOTIFICATION: 6328158,
} as const;
Expand Down
16 changes: 16 additions & 0 deletions src/mails/mails.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,22 @@ export class MailsService {
});
}

async sendRefererCandidateHasVerifiedAccountMail(
referer: User,
candidate: User
) {
await this.queuesService.addToWorkQueue(Jobs.SEND_MAIL, {
toEmail: referer.email,
templateId: MailjetTemplates.REFERER_CANDIDATE_HAS_FINALIZED_ACCOUNT,
variables: {
candidateFirstName: candidate.firstName,
candidateLastName: candidate.lastName,
refererFirstName: referer.firstName,
zone: candidate.zone,
},
});
}

async sendAdminNewRefererNotificationMail(referer: User) {
const adminFromZone = getAdminMailsFromZone(referer.zone);
await this.queuesService.addToWorkQueue(Jobs.SEND_MAIL, {
Expand Down

0 comments on commit dab413c

Please sign in to comment.