-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Envoi de l'email de creation de compte en asynchrone (PIX-1…
- Loading branch information
Showing
23 changed files
with
756 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
api/src/identity-access-management/domain/emails/create-account-creation.email.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { urlBuilder } from '../../../shared/infrastructure/utils/url-builder.js'; | ||
import { EmailFactory } from '../../../shared/mail/domain/models/EmailFactory.js'; | ||
import { mailer } from '../../../shared/mail/infrastructure/services/mailer.js'; | ||
|
||
export function createAccountCreationEmail({ locale, email, firstName, token, redirectionUrl }) { | ||
const factory = new EmailFactory({ app: 'pix-app', locale }); | ||
|
||
const { i18n, defaultVariables } = factory; | ||
|
||
const redirectUrl = redirectionUrl || defaultVariables.pixAppConnectionUrl; | ||
|
||
return factory.buildEmail({ | ||
template: mailer.accountCreationTemplateId, | ||
subject: i18n.__('pix-account-creation-email.subject'), | ||
to: email, | ||
variables: { | ||
homeName: defaultVariables.homeName, | ||
homeUrl: defaultVariables.homeUrl, | ||
helpdeskUrl: defaultVariables.helpdeskUrl, | ||
displayNationalLogo: defaultVariables.displayNationalLogo, | ||
askForHelp: i18n.__('pix-account-creation-email.params.askForHelp'), | ||
disclaimer: i18n.__('pix-account-creation-email.params.disclaimer'), | ||
doNotAnswer: i18n.__('pix-account-creation-email.params.doNotAnswer'), | ||
goToPix: i18n.__('pix-account-creation-email.params.goToPix'), | ||
helpdeskLinkLabel: i18n.__('pix-account-creation-email.params.helpdeskLinkLabel'), | ||
moreOn: i18n.__('pix-account-creation-email.params.moreOn'), | ||
pixPresentation: i18n.__('pix-account-creation-email.params.pixPresentation'), | ||
subtitle: i18n.__('pix-account-creation-email.params.subtitle'), | ||
subtitleDescription: i18n.__('pix-account-creation-email.params.subtitleDescription'), | ||
title: i18n.__('pix-account-creation-email.params.title', { firstName }), | ||
redirectionUrl: urlBuilder.getEmailValidationUrl({ locale, redirectUrl, token }), | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
api/src/shared/mail/application/jobs/send-email.job-controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { JobController } from '../../../application/jobs/job-controller.js'; | ||
import { Email } from '../../domain/models/Email.js'; | ||
import * as emailRepository from '../../infrastructure/repositories/email.repository.js'; | ||
|
||
export class SendEmailJobController extends JobController { | ||
constructor() { | ||
super('SendEmailJob'); | ||
} | ||
|
||
async handle({ data, dependencies = { emailRepository } }) { | ||
const email = new Email(data); | ||
await dependencies.emailRepository.sendEmail(email); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { config } from '../../config.js'; | ||
import { LOCALE } from '../../domain/constants.js'; | ||
|
||
// FRENCH_FRANCE | ||
const PIX_HOME_URL_FRENCH_FRANCE = `${config.domain.pix + config.domain.tldFr}`; | ||
const PIX_APP_URL_FRENCH_FRANCE = `${config.domain.pixApp + config.domain.tldFr}`; | ||
const PIX_ORGA_HOME_URL_FRENCH_FRANCE = `${config.domain.pixOrga + config.domain.tldFr}`; | ||
const PIX_CERTIF_HOME_URL_FRENCH_FRANCE = `${config.domain.pixCertif + config.domain.tldFr}`; | ||
|
||
const PIX_APP_CONNECTION_URL_FRENCH_FRANCE = `${PIX_APP_URL_FRENCH_FRANCE}/connexion`; | ||
const HELPDESK_FRENCH_FRANCE = 'https://pix.fr/support'; | ||
|
||
// INTERNATIONAL | ||
const PIX_HOME_URL_INTERNATIONAL_BASE = `${config.domain.pix + config.domain.tldOrg}`; | ||
const PIX_APP_URL_INTERNATIONAL = `${config.domain.pixApp + config.domain.tldOrg}`; | ||
const PIX_ORGA_HOME_URL_INTERNATIONAL = `${config.domain.pixOrga + config.domain.tldOrg}`; | ||
const PIX_CERTIF_HOME_URL_INTERNATIONAL = `${config.domain.pixCertif + config.domain.tldOrg}`; | ||
|
||
const PIX_HOME_URL_INTERNATIONAL = { | ||
en: `${PIX_HOME_URL_INTERNATIONAL_BASE}/en/`, | ||
es: `${PIX_HOME_URL_INTERNATIONAL_BASE}/en/`, | ||
fr: `${PIX_HOME_URL_INTERNATIONAL_BASE}/fr/`, | ||
nl: `${PIX_HOME_URL_INTERNATIONAL_BASE}/nl-be/`, | ||
}; | ||
const PIX_APP_CONNECTION_URL_INTERNATIONAL = { | ||
en: `${PIX_APP_URL_INTERNATIONAL}/connexion/?lang=en`, | ||
es: `${PIX_APP_URL_INTERNATIONAL}/connexion/?lang=es`, | ||
fr: `${PIX_APP_URL_INTERNATIONAL}/connexion/?lang=fr`, | ||
nl: `${PIX_APP_URL_INTERNATIONAL}/connexion/?lang=nl`, | ||
}; | ||
const PIX_HELPDESK_URL_INTERNATIONAL = { | ||
en: `${PIX_HOME_URL_INTERNATIONAL['en']}support`, | ||
es: `${PIX_HOME_URL_INTERNATIONAL['es']}support`, | ||
fr: `${PIX_HOME_URL_INTERNATIONAL['fr']}support`, | ||
nl: `${PIX_HOME_URL_INTERNATIONAL['nl']}support`, | ||
}; | ||
|
||
export function getEmailDefaultVariables(locale) { | ||
switch (locale) { | ||
case LOCALE.FRENCH_SPOKEN: | ||
case LOCALE.SPANISH_SPOKEN: | ||
case LOCALE.ENGLISH_SPOKEN: | ||
case LOCALE.DUTCH_SPOKEN: | ||
return { | ||
homeName: `pix${config.domain.tldOrg}`, | ||
homeUrl: PIX_HOME_URL_INTERNATIONAL[locale] ?? PIX_HOME_URL_INTERNATIONAL.en, | ||
pixOrgaHomeUrl: PIX_ORGA_HOME_URL_INTERNATIONAL, | ||
pixCertifHomeUrl: PIX_CERTIF_HOME_URL_INTERNATIONAL, | ||
pixAppConnectionUrl: PIX_APP_CONNECTION_URL_INTERNATIONAL[locale] ?? PIX_APP_CONNECTION_URL_INTERNATIONAL.en, | ||
helpdeskUrl: PIX_HELPDESK_URL_INTERNATIONAL[locale] ?? PIX_HELPDESK_URL_INTERNATIONAL.en, | ||
displayNationalLogo: false, | ||
}; | ||
default: | ||
return { | ||
homeName: `pix${config.domain.tldFr}`, | ||
homeUrl: PIX_HOME_URL_FRENCH_FRANCE, | ||
pixOrgaHomeUrl: PIX_ORGA_HOME_URL_FRENCH_FRANCE, | ||
pixCertifHomeUrl: PIX_CERTIF_HOME_URL_FRENCH_FRANCE, | ||
pixAppConnectionUrl: PIX_APP_CONNECTION_URL_FRENCH_FRANCE, | ||
helpdeskUrl: HELPDESK_FRENCH_FRANCE, | ||
displayNationalLogo: true, | ||
}; | ||
} | ||
} |
Oops, something went wrong.