requested changes

This commit is contained in:
Pau 2023-01-18 09:06:17 +01:00
parent cc806cc08f
commit a5f83021db
2 changed files with 13 additions and 15 deletions

View File

@ -47,22 +47,16 @@ module.exports = Self => {
}; };
async function getUserToModify(notificationId, userFk, models) { async function getUserToModify(notificationId, userFk, models) {
if (notificationId != null) { let userToModify = userFk;
if (notificationId) {
const subscription = await models.NotificationSubscription.findById(notificationId); const subscription = await models.NotificationSubscription.findById(notificationId);
const user = await subscription.userFk; userToModify = subscription.userFk;
return await models.Worker.findOne({
fields: ['id', 'bossFk'],
where: {
id: user
}
});
} else {
return await models.Worker.findOne({
fields: ['id', 'bossFk'],
where: {
id: userFk
}
});
} }
return await models.Worker.findOne({
fields: ['id', 'bossFk'],
where: {
id: userToModify
}
});
} }
}; };

View File

@ -0,0 +1,4 @@
ALTER TABLE
`util`.`notificationSubscription`
ADD
CONSTRAINT `notificationSubscription_UN` UNIQUE KEY (`notificationFk`, `userFk`);