4797-lilium-worker-notifications #1229

Merged
pau merged 37 commits from 4797-lilium-worker-notifications into dev 2023-02-02 08:53:29 +00:00
4 changed files with 69 additions and 1 deletions
Showing only changes of commit dfdf3d68bf - Show all commits

View File

@ -0,0 +1,56 @@
module.exports = Self => {
Self.remoteMethod('deleteSubscription', {
description: 'delete a notification subscription',
accessType: 'WRITE',
accepts: [
{
arg: 'notificationId',
type: 'string',
required: true
},
{
arg: 'userId',
type: 'string',
required: true
}
],
returns: {
type: 'object',
root: true
},
http: {
path: `/deleteSubscription`,
verb: 'POST'
}
});
Self.deleteSubscription = async(notificationId, userId, options) => {
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const query = `DELETE FROM util.notificationSubscription
WHERE notificationFk = ? AND userFk = ?`;
await Self.rawSql(query, [notificationId, userId], myOptions);
if (tx) await tx.commit();
return {success: true};
} catch (error) {
if (tx) await tx.rollback();
throw error;
}
};
};

View File

@ -6,6 +6,16 @@
"table": "util.notificationAcl"
}
},
"properties":{
"notificationFk": {
"id": true,
"type": "number"
},
"roleFk":{
"id": true,
"type": "number"
}
},
"relations": {
"notification": {
"type": "belongsTo",

View File

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

View File

@ -9,7 +9,6 @@
"properties": {
"notificationFk": {
"type": "number",
"id": true,
"description": "Identifier"
},
"userFk": {