From 37a552394083351214feccfc845acf951fb9b3ef Mon Sep 17 00:00:00 2001 From: Wanderson Santos <81826043+wandersonDeve@users.noreply.github.com> Date: Thu, 5 Oct 2023 12:17:55 -0300 Subject: [PATCH] fix: send email --- package.json | 1 + src/modules/mails/send-mail.controller.ts | 2 +- src/modules/mails/send-mail.service.ts | 14 +++++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 9827992..abe6843 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", "start:dev": "nest start --watch", + "dev": "nest start --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", diff --git a/src/modules/mails/send-mail.controller.ts b/src/modules/mails/send-mail.controller.ts index d9c3dc0..2e88a29 100644 --- a/src/modules/mails/send-mail.controller.ts +++ b/src/modules/mails/send-mail.controller.ts @@ -43,6 +43,6 @@ export class SendMailController { @Post('/collaborator') @HttpCode(200) async sendMail(@Body() data: any) { - return await this.sendMailService.send(data, 'apoiador'); + return await this.sendMailService.send(data, data.subject); } } diff --git a/src/modules/mails/send-mail.service.ts b/src/modules/mails/send-mail.service.ts index 03e568a..6abdef5 100644 --- a/src/modules/mails/send-mail.service.ts +++ b/src/modules/mails/send-mail.service.ts @@ -20,23 +20,23 @@ export class SendMailService { const emailToSend = NODE_ENV === 'development' ? EMAIL_TESTE : EMAIL_PROD; await this.mailProvider.send({ - context: { data }, + context: data, subject, template: './ombudsman', to: emailToSend, }); - if (data.subject === 'Quero ser Mentor') { + if (subject === 'Quero ser Mentor') { await this.mailProvider.send({ context: { - CANDIDATE_FIRST_NAME: data?.name || 'Aquele que não deve ser nomeado', - JOB_NAME: data?.areas || '', - LINKEDIN_URL: data?.linkedin || '', - MESSAGE: data?.mensagem || '', + FULL_NAME: data?.data?.name || 'Aquele que não deve ser nomeado', + JOB_NAME: data?.data?.areas || '', + LINKEDIN_URL: data?.data?.linkedin || '', + MESSAGE: data?.data?.mensagem || '', }, subject: 'Recebemos seu email', template: './response-user', - to: data.email, + to: data.data.email, }); } }