4797-lilium-worker-notifications #1229

Merged
pau merged 37 commits from 4797-lilium-worker-notifications into dev 2023-02-02 08:53:29 +00:00
2 changed files with 13 additions and 15 deletions
Showing only changes of commit a5f83021db - Show all commits

View File

@ -47,22 +47,16 @@ module.exports = Self => {
};
pau marked this conversation as resolved
Review

Self.deleteNotification = async function(ctx, userId, notificationId)

Y asi te ahorras poner

const notificationId = await ctx.args.notificationId;
const userId = await ctx.args.userId;
`Self.deleteNotification = async function(ctx, userId, notificationId)` Y asi te ahorras poner ``` const notificationId = await ctx.args.notificationId; const userId = await ctx.args.userId; ```
async function getUserToModify(notificationId, userFk, models) {
pau marked this conversation as resolved Outdated
Outdated
Review

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
Outdated
Review

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
    }
});
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
Outdated
Review

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
Review

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
}
});
}
};

View File

@ -0,0 +1,4 @@
ALTER TABLE
pau marked this conversation as resolved Outdated
Outdated
Review

deuria anar en la 230401

deuria anar en la 230401
`util`.`notificationSubscription`
ADD
CONSTRAINT `notificationSubscription_UN` UNIQUE KEY (`notificationFk`, `userFk`);