4320-notificationQueue #1087

Merged
alexm merged 15 commits from 4320-notificationQueue into dev 2022-10-28 06:06:04 +00:00
10 changed files with 70 additions and 20 deletions
Showing only changes of commit 9b48cbb078 - Show all commits

View File

@ -1,7 +1,7 @@
module.exports = Self => {
Self.remoteMethod('send', {
description: 'Send notifications from queue',
accessType: 'WRITE',
accessType: 'READ',
returns: {
type: 'object',
root: true
@ -13,6 +13,23 @@ module.exports = Self => {
});
Self.send = async() => {
const status = 'pending';
const myOptions = {};
let tx;
alexm marked this conversation as resolved
Review

En test no tiene que lanzar error y debe ejecutar todo el código a excepción de la linea que envía el correo, así se puede comprobar que el proceso funciona correctamente.

En test no tiene que lanzar error y debe ejecutar todo el código a excepción de la linea que envía el correo, así se puede comprobar que el proceso funciona correctamente.
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
const notificationQueue = await Self.app.models.NotificationQueue.find({
where: {code: status},
include: [{
relation: 'notificationSubscription'
}]
}, myOptions);
console.log(notificationQueue);
};
};

View File

@ -77,6 +77,21 @@
"Module": {
"dataSource": "vn"
},
"Notification": {
"dataSource": "vn"
},
"NotificationAcl": {
"dataSource": "vn"
},
"NotificationConfig": {
"dataSource": "vn"
},
"NotificationQueue": {
"dataSource": "vn"
},
"NotificationSubscription": {
"dataSource": "vn"
},
"Province": {
"dataSource": "vn"
},

View File

@ -1,4 +1,3 @@
module.exports = Self => {
require('../methods/notification/send')(Self);
require('../methods/notification/clear')(Self);
};

View File

@ -1,9 +1,9 @@
{
"name": "Notificacion",
"name": "Notification",
"base": "VnModel",
"options": {
"mysql": {
"table": "notificacion"
"table": "util.notification"
}
},
"properties": {

View File

@ -1,16 +1,16 @@
{
"name": "NotificacionAcl",
"name": "NotificationAcl",
"base": "VnModel",
"options": {
"mysql": {
"table": "notificacionAcl"
"table": "util.notificationAcl"
}
},
"relations": {
"notificacion": {
"notification": {
"type": "belongsTo",
"model": "Notificacion",
"foreignKey": "notificacionFk"
"model": "Notification",
"foreignKey": "notificationFk"
},
"role": {
"type": "belongsTo",

View File

@ -3,7 +3,7 @@
"base": "VnModel",
"options": {
"mysql": {
"table": "notificationConfig"
"table": "util.notificationConfig"
}
},
"properties": {

View File

@ -1,9 +1,9 @@
{
"name": "NotificacionQueue",
"name": "NotificationQueue",
"base": "VnModel",
"options": {
"mysql": {
"table": "notificacionQueue"
"table": "util.notificationQueue"
}
},
"properties": {
@ -23,10 +23,10 @@
}
},
"relations": {
"notificacion": {
"notification": {
"type": "belongsTo",
"model": "Notificacion",
"foreignKey": "notificacionFk"
"model": "Notification",
"foreignKey": "notificationFk"
},
"author": {
"type": "belongsTo",

View File

@ -3,14 +3,14 @@
"base": "VnModel",
"options": {
"mysql": {
"table": "notificationSubscription"
"table": "util.notificationSubscription"
}
},
"relations": {
"notificacion": {
"notification": {
"type": "belongsTo",
"model": "Notificacion",
"foreignKey": "notificacionFk"
"model": "Notification",
"foreignKey": "notificationFk"
},
"user": {
"type": "belongsTo",

View File

@ -0,0 +1,3 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES
('Notification', '*', 'READ', 'ALLOW', 'ROLE', 'developer');

View File

@ -2613,4 +2613,20 @@ INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`,
(1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13);
INSERT INTO `util`.`notificationConfig`
SET `cleanDays` = 90;
SET `cleanDays` = 90;
INSERT INTO `util`.`notification` (`id`, `name`, `description`)
VALUES
(1, 'notification one', 'notification fixture one');
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
VALUES
(1, 9);
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
VALUES
(1, 'notification one', 'randomParams', 9, 'pending', util.VN_CURDATE());
INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
VALUES
(1, 1110);