Skip to content

Commit

Permalink
feat(api): build account creation email with EmailFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
bpetetot committed Nov 7, 2024
1 parent 196e6aa commit 8c6e287
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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 { buildEmail, i18n, defaultVariables } = new EmailFactory({ app: 'pix-app', locale });

const redirectUrl = redirectionUrl || defaultVariables.pixAppConnectionUrl;

return 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 }),
},
});
}

// const email = createAccountCreationEmail({ ... });
// await emailRepository.send(email);

0 comments on commit 8c6e287

Please sign in to comment.