feat(notification): send
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
7895decf4e
commit
9b48cbb078
|
@ -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;
|
||||
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/notification/send')(Self);
|
||||
require('../methods/notification/clear')(Self);
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "Notificacion",
|
||||
"name": "Notification",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "notificacion"
|
||||
"table": "util.notification"
|
||||
}
|
||||
},
|
||||
"properties": {
|
|
@ -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",
|
|
@ -3,7 +3,7 @@
|
|||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "notificationConfig"
|
||||
"table": "util.notificationConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
|
@ -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",
|
|
@ -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",
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Notification', '*', 'READ', 'ALLOW', 'ROLE', 'developer');
|
|
@ -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);
|
Loading…
Reference in New Issue