From d70d848717b993d0ebeb08cf216b59f576630aee Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 18 Nov 2022 09:57:07 +0100 Subject: [PATCH] fix: use vn email --- back/methods/notification/clean.js | 7 +++++-- back/methods/notification/send.js | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/back/methods/notification/clean.js b/back/methods/notification/clean.js index e6da58af8..bdc6737df 100644 --- a/back/methods/notification/clean.js +++ b/back/methods/notification/clean.js @@ -29,6 +29,9 @@ module.exports = Self => { try { const config = await models.NotificationConfig.findOne({}, myOptions); + + if (!config.cleanDays) return; + const cleanDate = new Date(); cleanDate.setDate(cleanDate.getDate() - config.cleanDays); @@ -36,11 +39,11 @@ module.exports = Self => { where: {status: {inq: status}}, created: {lt: cleanDate} }, myOptions); - - if (tx) await tx.commit(); } catch (e) { if (tx) await tx.rollback(); throw e; } + + if (tx) await tx.commit(); }; }; diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index 80faf0305..2adb9c5f5 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -1,5 +1,4 @@ const {Email} = require('vn-print'); -const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethod('send', { @@ -35,7 +34,7 @@ module.exports = Self => { include: { relation: 'user', scope: { - fields: ['name', 'email', 'lang'] + fields: ['name', 'lang'] } } } @@ -56,7 +55,7 @@ module.exports = Self => { for (const notificationUser of queue.notification().subscription()) { try { const sendParams = { - recipient: notificationUser.user().email, + recipient: notificationUser.user().name + '@verdnatura.es', lang: notificationUser.user().lang };