Fix some issues
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 36s
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 36s
This commit is contained in:
parent
1b522c0df4
commit
5d7baeb433
@ -14,7 +14,8 @@
|
||||
"express": "^4.18.2",
|
||||
"node-fetch": "^2.6.7",
|
||||
"ovh": "^2.0.3",
|
||||
"stripe": "^18.3.0"
|
||||
"stripe": "^18.3.0",
|
||||
"uuid": "^11.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^3.0.1"
|
||||
|
@ -613,6 +613,73 @@ app.post('/api/subscribe-to-list', validateEmail, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/:uid/send_reminder', validateEmail, async (req, res) => {
|
||||
const { email, documentsUid } = req.body;
|
||||
|
||||
try {
|
||||
const uid = req.params["uid"];
|
||||
if (!uid) {
|
||||
//this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!documentsUid || !Array.isArray(documentsUid)) {
|
||||
//this.httpBadRequest(response, "Invalid or missing documents");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
const documentEntities: Documents[] = [];
|
||||
//For each document uid, use DocumentsService.getByUid to get the document entity and add it to the documents array
|
||||
for (const documentUid of documentsUid) {
|
||||
const documentEntity = await this.documentsService.getByUid(documentUid, { document_type: true, folder: true });
|
||||
|
||||
if (!documentEntity) {
|
||||
this.httpBadRequest(response, "Document not found");
|
||||
return;
|
||||
}
|
||||
documentEntities.push(documentEntity);
|
||||
}
|
||||
|
||||
const customerEntity = await this.customersService.getByUid(uid, { contact: true, office: true });
|
||||
|
||||
if (!customerEntity) {
|
||||
this.httpNotFoundRequest(response, "customer not found");
|
||||
return;
|
||||
}
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const customer = Customer.hydrate < Customer > (customerEntity, { strategy: "excludeAll" });
|
||||
|
||||
// Call service to send reminder with documents
|
||||
await this.customersService.sendDocumentsReminder(customer, documentEntities);
|
||||
*/
|
||||
|
||||
const templateVariables = {
|
||||
first_name: 'firstName' || '',
|
||||
last_name: 'lastName' || '',
|
||||
office_name: 'officeName' || '',
|
||||
link: `${process.env.APP_HOST}`
|
||||
};
|
||||
|
||||
const result = await EmailService.sendTransactionalEmail(
|
||||
email,
|
||||
ETemplates.DOCUMENT_REMINDER,
|
||||
'Votre notaire vous envoie un message',
|
||||
templateVariables
|
||||
);
|
||||
console.log(result);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
message: 'Email envoyé avec succès'
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
// Automatic retry system
|
||||
setInterval(() => {
|
||||
EmailService.retryFailedEmails();
|
||||
|
Loading…
x
Reference in New Issue
Block a user