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 => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('send', {
|
Self.remoteMethod('send', {
|
||||||
description: 'Send notifications from queue',
|
description: 'Send notifications from queue',
|
||||||
accessType: 'WRITE',
|
accessType: 'READ',
|
||||||
returns: {
|
returns: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
root: true
|
root: true
|
||||||
|
@ -13,6 +13,23 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.send = async() => {
|
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": {
|
"Module": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"Notification": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"NotificationAcl": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"NotificationConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"NotificationQueue": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"NotificationSubscription": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"Province": {
|
"Province": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/notification/send')(Self);
|
require('../methods/notification/send')(Self);
|
||||||
require('../methods/notification/clear')(Self);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Notificacion",
|
"name": "Notification",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "notificacion"
|
"table": "util.notification"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
|
@ -1,16 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "NotificacionAcl",
|
"name": "NotificationAcl",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "notificacionAcl"
|
"table": "util.notificationAcl"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"notificacion": {
|
"notification": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Notificacion",
|
"model": "Notification",
|
||||||
"foreignKey": "notificacionFk"
|
"foreignKey": "notificationFk"
|
||||||
},
|
},
|
||||||
"role": {
|
"role": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
|
@ -3,7 +3,7 @@
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "notificationConfig"
|
"table": "util.notificationConfig"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "NotificacionQueue",
|
"name": "NotificationQueue",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "notificacionQueue"
|
"table": "util.notificationQueue"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -23,10 +23,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"notificacion": {
|
"notification": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Notificacion",
|
"model": "Notification",
|
||||||
"foreignKey": "notificacionFk"
|
"foreignKey": "notificationFk"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
|
@ -3,14 +3,14 @@
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "notificationSubscription"
|
"table": "util.notificationSubscription"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"notificacion": {
|
"notification": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Notificacion",
|
"model": "Notification",
|
||||||
"foreignKey": "notificacionFk"
|
"foreignKey": "notificationFk"
|
||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Notification', '*', 'READ', 'ALLOW', 'ROLE', 'developer');
|
|
@ -2614,3 +2614,19 @@ INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`,
|
||||||
|
|
||||||
INSERT INTO `util`.`notificationConfig`
|
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