requested changes
This commit is contained in:
parent
cc806cc08f
commit
a5f83021db
|
@ -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
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
ALTER TABLE
|
||||||
|
`util`.`notificationSubscription`
|
||||||
|
ADD
|
||||||
|
CONSTRAINT `notificationSubscription_UN` UNIQUE KEY (`notificationFk`, `userFk`);
|
Loading…
Reference in New Issue