From 51c8d77ba492906f9c18fde1a6ad307b9b8c86be Mon Sep 17 00:00:00 2001 From: antoinefa Date: Thu, 22 Apr 2021 00:06:09 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20handles=20reject=20as=20a=20requ?= =?UTF-8?q?est=20for=20change=20in=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/mail.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/src/mail.ts b/backend/src/mail.ts index a8b4bb9f..b01f4f63 100644 --- a/backend/src/mail.ts +++ b/backend/src/mail.ts @@ -1,4 +1,5 @@ import { SMTPClient } from 'emailjs'; +import { ReviewStatus } from './models/entities'; const client = new SMTPClient({ host: process.env.SMTP_HOST, @@ -40,29 +41,32 @@ export const validateOTP = (email:string,otp:string): boolean => { return false; } -export const sendUpdateConfirmation = async (email:string, validation: boolean, rejectMsg: string, id: string): Promise => { +export const sendUpdateConfirmation = async (email:string, status: ReviewStatus, rejectMsg: string, id: string): Promise => { try { const message: any = { from: process.env.API_EMAIL, to: `${email}`, } - if (validation) { + if (status === 'validated') { message.subject = `Suggestion validée ! - ${process.env.APP_DNS}`; message.attachment = { data: `

Merci de votre contibution !

Votre proposition de correction a été acceptée.
Retrouvez la fiche modifiée .

+ Vous pouvez à tout moment revenir sur vos contributions.
+
l'équipe matchID `, alternative: true}; - } else { - message.subject = `Suggestion non retenue - ${process.env.APP_DNS}`; + } else if (status === 'rejected') { + message.subject = `Suggestion incomplète - ${process.env.APP_DNS}`; message.attachment = { data: ` Nous vous remercions de votre contribution,

- Néanmoins les éléments fournis ne nous ont pas permis de retenir votre proposition
- ${rejectMsg ? rejectMsg : ''}
+ Néanmoins les éléments fournis ne nous ont pas permis de retenir votre proposition à ce stade.
+ ${rejectMsg ? '
' + rejectMsg + '
' : ''}
+ Vous pourrez de nouveau soumettre une nouvelle proposition sur la fiche: .

l'équipe matchID