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

View File

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