2666 - Closure invalid email notification
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
e70b8a80e1
commit
6416b0ad79
|
@ -4,6 +4,8 @@ import './style.scss';
|
|||
|
||||
export default class DescriptorPopover extends Popover {
|
||||
show(parent, id) {
|
||||
if (!id) return;
|
||||
|
||||
super.show(parent);
|
||||
|
||||
this.id = id;
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
<vn-td>{{::tracking.state.name}}</vn-td>
|
||||
<vn-td expand>
|
||||
<span
|
||||
class="link"
|
||||
ng-class="{'link': tracking.worker.id}"
|
||||
ng-click="workerDescriptor.show($event, tracking.worker.user.id)">
|
||||
{{::tracking.worker.user.name | dashIfEmpty}}
|
||||
{{::tracking.worker.user.name || 'System' | translate}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::tracking.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<span
|
||||
ng-class="{'link': log.user.worker.id, 'value': !log.user.worker.id}"
|
||||
ng-click="$ctrl.showWorkerDescriptor($event, log.user.worker.id)"
|
||||
translate>{{::log.user.name | dashIfEmpty}}
|
||||
translate>{{::log.user.name || 'System' | translate}}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -54,7 +54,7 @@
|
|||
<span
|
||||
ng-class="{'link': log.user.worker.id, 'value': !log.user.worker.id}"
|
||||
ng-click="$ctrl.showWorkerDescriptor($event, log.user.worker.id)"
|
||||
translate>{{::log.user.name | dashIfEmpty}}
|
||||
translate>{{::log.user.name || 'System' | translate}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td class="expendable">
|
||||
|
@ -70,7 +70,7 @@
|
|||
<vn-one ng-repeat="old in log.oldProperties">
|
||||
<div>
|
||||
<span translate class="label">{{::old.key}}</span><span class="label">: </span>
|
||||
<span translate class="value">{{::old.value}}</span>
|
||||
<span translate class="value">{{::old.value | dashIfEmpty}}</span>
|
||||
</div>
|
||||
</vn-one>
|
||||
</vn-td>
|
||||
|
@ -81,7 +81,7 @@
|
|||
id="newInstance">
|
||||
<div>
|
||||
<span translate class="label">{{::new.key}}</span><span class="label">: </span>
|
||||
<span translate class="value">{{::new.value}}</span>
|
||||
<span translate class="value">{{::new.value | dashIfEmpty}}</span>
|
||||
</div>
|
||||
</vn-one>
|
||||
<vn-one
|
||||
|
|
|
@ -9,4 +9,5 @@ Name: Nombre
|
|||
Creates: Crea
|
||||
Updates: Actualiza
|
||||
Deletes: Elimina
|
||||
Views: Visualiza
|
||||
Views: Visualiza
|
||||
System: Sistema
|
|
@ -151,6 +151,7 @@ module.exports = app => {
|
|||
SELECT
|
||||
t.id,
|
||||
t.clientFk,
|
||||
c.name clientName,
|
||||
c.email recipient,
|
||||
c.salesPersonFk,
|
||||
c.isToBeMailed,
|
||||
|
@ -196,6 +197,10 @@ module.exports = app => {
|
|||
const email = new Email('delivery-note-link', args);
|
||||
await email.send();
|
||||
} catch (error) {
|
||||
// Domain not found
|
||||
if (error.responseCode == 450)
|
||||
return invalidEmail(ticket);
|
||||
|
||||
// Save tickets on a list of failed ids
|
||||
failedtickets.push({
|
||||
id: ticket.id,
|
||||
|
@ -220,4 +225,33 @@ module.exports = app => {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function invalidEmail(ticket) {
|
||||
await db.rawSql(`UPDATE client SET email = NULL WHERE id = :clientId`, {
|
||||
clientId: ticket.clientFk
|
||||
});
|
||||
|
||||
const oldInstance = `{"email": "${ticket.recipient}"}`;
|
||||
const newInstance = `{"email": ""}`;
|
||||
await db.rawSql(`
|
||||
INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance)
|
||||
VALUES (:clientId, :userId, 'UPDATE', 'Client', :oldInstance, :newInstance)`, {
|
||||
clientId: ticket.clientFk,
|
||||
userId: null,
|
||||
oldInstance: oldInstance,
|
||||
newInstance: newInstance
|
||||
});
|
||||
|
||||
const body = `No se ha podido enviar el albarán <strong>${ticket.id}</strong>
|
||||
al cliente <strong>${ticket.clientFk} - ${ticket.clientName}</strong>
|
||||
porque la dirección de email <strong>"${ticket.recipient}"</strong> no es correcta o no está disponible.<br/><br/>
|
||||
Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente.
|
||||
Actualiza la dirección de email con una correcta.`;
|
||||
|
||||
smtp.send({
|
||||
to: ticket.salesPersonEmail,
|
||||
subject: 'No se ha podido enviar el albarán',
|
||||
html: body
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue