requested changes
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pau 2023-01-03 08:12:46 +01:00
parent 45d4ab80d5
commit a55d007655
2 changed files with 11 additions and 24 deletions

View File

@ -14,7 +14,7 @@ module.exports = Self => {
}); });
Self.remoteMethod('deleteNotification', { Self.remoteMethod('deleteNotification', {
description: 'Gets the current user data', description: 'Deletes a notification subscription',
accepts: [ accepts: [
{ {
arg: 'ctx', arg: 'ctx',
@ -22,15 +22,11 @@ module.exports = Self => {
http: {source: 'context'} http: {source: 'context'}
}, },
{ {
arg: 'userId', arg: 'userFk',
type: 'string' type: 'string'
}, },
{ {
arg: 'notificationId', arg: 'notificationFk',
type: 'number'
},
{
arg: 'authorId',
type: 'number' type: 'number'
} }
], ],
@ -44,18 +40,16 @@ module.exports = Self => {
} }
}); });
Self.deleteNotification = async function(ctx) { Self.deleteNotification = async function(ctx, userFk, notificationFk) {
const models = Self.app.models; const models = Self.app.models;
const user = await ctx.args.authorId; const user = ctx.req.accessToken.userId;
const notificationId = await ctx.args.notificationId; const modifiedUser = await getUserToModify(userFk, models);
const userId = await ctx.args.userId;
const modifiedUser = await getUserToModify(userId, models);
if (user == modifiedUser.id || modifiedUser.bossFk == user) { if (user == modifiedUser.id || modifiedUser.bossFk == user) {
const query = `DELETE FROM util.notificationSubscription const query = `DELETE FROM util.notificationSubscription
WHERE notificationFk = ? AND userFk = ?`; WHERE notificationFk = ? AND userFk = ?`;
await Self.rawSql(query, [notificationId, userId]); await Self.rawSql(query, [notificationFk, userFk]);
return; return;
} else } else

View File

@ -1,11 +1,4 @@
INSERT INTO INSERT INTO `salix`.`ACL` (model,property,accessType,principalId)
`salix`.`ACL` ( VALUES ('NotificationSubscription','*','*','employee');
`model`, INSERT INTO `salix`.`ACL` (model,property,accessType,principalId)
`property`, VALUES ('NotificationAcl','*','*','employee');
`accessType`,
`permission`,
`principalId`
)
VALUES
('NotificationSubscription', '*', '*', 'employee'),
('NotificationAcl', '*', '*', 'employee');