Skip to content

Commit

Permalink
feat(api): add self delete-user account notification email
Browse files Browse the repository at this point in the history
  • Loading branch information
lego-technix committed Dec 5, 2024
1 parent 7e83195 commit 2ac796c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { EmailFactory } from '../../../shared/mail/domain/models/EmailFactory.js';
import { mailer } from '../../../shared/mail/infrastructure/services/mailer.js';

export function createSelfDeleteUserAccountEmail({ locale, email, firstName }) {
const factory = new EmailFactory({ app: 'pix-app', locale });

const { i18n, defaultVariables } = factory;

return factory.buildEmail({
template: mailer.selfAccountDeletionTemplateId,
subject: i18n.__('self-account-deletion-email.subject'),
to: email,
variables: {
homeName: defaultVariables.homeName,
homeUrl: defaultVariables.homeUrl,
helpdeskUrl: defaultVariables.helpdeskUrl,
displayNationalLogo: defaultVariables.displayNationalLogo,
doNotAnswer: i18n.__('common.email.m doNotAnswer'),
moreOn: i18n.__('common.email.moreOn'),
pixPresentation: i18n.__('common.email.pixPresentation'),
title: i18n.__('self-account-deletion-email.params.title', { firstName }),
// "contactUs"
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { createSelfDeleteUserAccountEmail } from '../../../../../src/identity-access-management/domain/emails/create-self-delete-user-account.email.js';
import { Email } from '../../../../../src/shared/mail/domain/models/Email.js';
import { mailer } from '../../../../../src/shared/mail/infrastructure/services/mailer.js';
import { expect } from '../../../../test-helper.js';

describe('Unit | Identity Access Management | Domain | Email | create-self-delete-user-account', function () {
it('creates self delete user account email with correct parameters', function () {
const emailParams = {
locale: 'fr',
email: '[email protected]',
firstName: 'John',
token: '12345',
};

const email = createSelfDeleteUserAccountEmail(emailParams);

expect(email).to.be.instanceof(Email);
expect(email).to.have.property('subject').that.is.a('string');
expect(email.to).to.equal(emailParams.email);
expect(email.template).to.equal(mailer.selfAccountDeletionTemplateId);

const variables = email.variables;
expect(variables).to.have.property('displayNationalLogo').that.is.a('boolean');
expect(variables).to.have.property('doNotAnswer').that.is.a('string');
expect(variables).to.have.property('helpdeskUrl').that.is.a('string');
expect(variables).to.have.property('homeName').that.is.a('string');
expect(variables).to.have.property('homeUrl').that.is.a('string');
expect(variables).to.have.property('moreOn').that.is.a('string');
expect(variables).to.have.property('pixPresentation').that.is.a('string');
expect(variables).to.have.property('title').that.is.a('string');
});
});
8 changes: 4 additions & 4 deletions api/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@
"self-account-deletion-email": {
"params": {
"hello": "Hello {firstName},",
"requestConfirmation": "Following your request, we can confirm that your Pix account and personal data have been deleted.",
"seeYouSoon": "We hope to see you soon for new digital adventures.",
"signing": "The Pix team",
"requestConfirmation": "XXX",
"seeYouSoon": "XXX",
"signing": "XXX",
"title": "Deleting your account",
"warning": "If you are not the source of this request, please contact support."
"warning": "XXX"
},
"subject": "Deleting your account"
},
Expand Down

0 comments on commit 2ac796c

Please sign in to comment.