[master → test] Hacer primero #1167

Merged
joan merged 8 commits from master into test 2022-11-22 12:52:46 +00:00
2 changed files with 10 additions and 5 deletions
Showing only changes of commit 3d3a317b52 - Show all commits

View File

@ -29,6 +29,9 @@ module.exports = Self => {
try { try {
const config = await models.NotificationConfig.findOne({}, myOptions); const config = await models.NotificationConfig.findOne({}, myOptions);
if (!config.cleanDays) return;
const cleanDate = new Date(); const cleanDate = new Date();
cleanDate.setDate(cleanDate.getDate() - config.cleanDays); cleanDate.setDate(cleanDate.getDate() - config.cleanDays);
@ -36,11 +39,11 @@ module.exports = Self => {
where: {status: {inq: status}}, where: {status: {inq: status}},
created: {lt: cleanDate} created: {lt: cleanDate}
}, myOptions); }, myOptions);
if (tx) await tx.commit();
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();
throw e; throw e;
} }
if (tx) await tx.commit();
}; };
}; };

View File

@ -1,5 +1,4 @@
const {Email} = require('vn-print'); const {Email} = require('vn-print');
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('send', { Self.remoteMethod('send', {
@ -35,7 +34,10 @@ module.exports = Self => {
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {
fields: ['name', 'email', 'lang'] fields: ['name', 'lang'],
include: {
relation: 'emailUser'
}
} }
} }
} }
@ -56,7 +58,7 @@ module.exports = Self => {
for (const notificationUser of queue.notification().subscription()) { for (const notificationUser of queue.notification().subscription()) {
try { try {
const sendParams = { const sendParams = {
recipient: notificationUser.user().email, recipient: notificationUser.user().emailUser().email,
lang: notificationUser.user().lang lang: notificationUser.user().lang
}; };