4797-lilium-worker-notifications #1229
|
@ -47,22 +47,16 @@ module.exports = Self => {
|
|||
};
|
||||
pau marked this conversation as resolved
|
||||
|
||||
async function getUserToModify(notificationId, userFk, models) {
|
||||
pau marked this conversation as resolved
Outdated
alexm
commented
No seria mejor utilizar ctx.req.accessToken.userId y no pasarlo por parametro? No seria mejor utilizar ctx.req.accessToken.userId y no pasarlo por parametro?
|
||||
if (notificationId != null) {
|
||||
let userToModify = userFk;
|
||||
pau marked this conversation as resolved
Outdated
alexm
commented
Provar:
Provar:
let userToCheck = userFk;
if (notificationId != null)
userToCheck = await models.NotificationSubscription.findById(notificationId).userFk;
return await models.Worker.findOne({
fields: ['id', 'bossFk'],
where: {
id: userToCheck
}
});
|
||||
if (notificationId) {
|
||||
pau marked this conversation as resolved
Outdated
joan
commented
Además de lo que comenta alex, quitar el await. Además de lo que comenta alex, quitar el await.
|
||||
const subscription = await models.NotificationSubscription.findById(notificationId);
|
||||
pau marked this conversation as resolved
alexm
commented
Pq per defecte els dos parametres son null? Pq per defecte els dos parametres son null?
|
||||
const user = await 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
|
||||
}
|
||||
});
|
||||
userToModify = subscription.userFk;
|
||||
}
|
||||
return await models.Worker.findOne({
|
||||
fields: ['id', 'bossFk'],
|
||||
where: {
|
||||
id: userToModify
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE
|
||||
pau marked this conversation as resolved
Outdated
alexm
commented
deuria anar en la 230401 deuria anar en la 230401
|
||||
`util`.`notificationSubscription`
|
||||
ADD
|
||||
CONSTRAINT `notificationSubscription_UN` UNIQUE KEY (`notificationFk`, `userFk`);
|
Loading…
Reference in New Issue
Self.deleteNotification = async function(ctx, userId, notificationId)
Y asi te ahorras poner