fix anti-spam feature
This commit is contained in:
parent
8946108b20
commit
e26f4eecc5
@ -15,12 +15,19 @@ export default class EmailBuilder{
|
|||||||
public async sendDocumentEmails(documentEntity: Documents){
|
public async sendDocumentEmails(documentEntity: Documents){
|
||||||
if(documentEntity.document_status !== "ASKED" && documentEntity.document_status !== "REFUSED") return;
|
if(documentEntity.document_status !== "ASKED" && documentEntity.document_status !== "REFUSED") return;
|
||||||
|
|
||||||
|
let templateName = ETemplates.DOCUMENT_ASKED;
|
||||||
|
let subject = "Votre notaire vous demande de déposer des pièces pour traiter votre dossier.";
|
||||||
|
if(documentEntity.document_status === "REFUSED"){
|
||||||
|
templateName = ETemplates.DOCUMENT_REFUSED;
|
||||||
|
subject = "Un ou plusieurs documents ne sont pas validés. Vous avez une nouvelle action à réaliser.";
|
||||||
|
}
|
||||||
|
|
||||||
const documentPrisma = await this.documentsService.getByUid(documentEntity.uid, { depositor: {include: {contact: true}}, folder:{include:{ office: true}} });
|
const documentPrisma = await this.documentsService.getByUid(documentEntity.uid, { depositor: {include: {contact: true}}, folder:{include:{ office: true}} });
|
||||||
if(!documentPrisma) throw new Error("Document not found");
|
if(!documentPrisma) throw new Error("Document not found");
|
||||||
const document = Document.hydrate<Document>(documentPrisma);
|
const document = Document.hydrate<Document>(documentPrisma);
|
||||||
|
|
||||||
//Use mailchimpService.get get if an email was sent to the user in the lst hour
|
//Use mailchimpService.get get if an email was sent to the user in the lst hour
|
||||||
const lastEmail = await this.mailchimpService.get({ where: { to: document.depositor!.contact!.email, sentAt: { gte: new Date(Date.now() - 3600000) } } });
|
const lastEmail = await this.mailchimpService.get({ where: { to: document.depositor!.contact!.email, sentAt: { gte: new Date(Date.now() - 3600000) }, templateName: templateName} });
|
||||||
if(lastEmail.length > 0) return;
|
if(lastEmail.length > 0) return;
|
||||||
|
|
||||||
const to = document.depositor!.contact!.email;
|
const to = document.depositor!.contact!.email;
|
||||||
@ -31,13 +38,6 @@ export default class EmailBuilder{
|
|||||||
link: `${this.variables.APP_HOST}/customer-login`
|
link: `${this.variables.APP_HOST}/customer-login`
|
||||||
};
|
};
|
||||||
|
|
||||||
let templateName = ETemplates.DOCUMENT_ASKED;
|
|
||||||
let subject = "Votre notaire vous demande de déposer des pièces pour traiter votre dossier.";
|
|
||||||
if(documentEntity.document_status === "REFUSED"){
|
|
||||||
templateName = ETemplates.DOCUMENT_REFUSED;
|
|
||||||
subject = "Un ou plusieurs documents ne sont pas validés. Vous avez une nouvelle action à réaliser.";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mailchimpService.create({
|
this.mailchimpService.create({
|
||||||
templateName,
|
templateName,
|
||||||
to,
|
to,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user