feat: enhance vacation approval process by adding notification system for employees, including email alerts and in-app notifications; improve error handling and user feedback during vacation management
This commit is contained in:
@@ -859,7 +859,11 @@ export const marcarNotificacaoLida = mutation({
|
||||
if (!usuarioAtual) throw new Error('Não autenticado');
|
||||
|
||||
const notificacao = await ctx.db.get(args.notificacaoId);
|
||||
if (!notificacao) throw new Error('Notificação não encontrada');
|
||||
// Se a notificação não existe (já foi deletada), retornar sucesso silenciosamente
|
||||
// Isso evita erros quando múltiplas tentativas são feitas ou quando a notificação já foi removida
|
||||
if (!notificacao) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// SEGURANÇA: Verificar se a notificação pertence ao usuário atual
|
||||
if (notificacao.usuarioId !== usuarioAtual._id) {
|
||||
@@ -874,6 +878,11 @@ export const marcarNotificacaoLida = mutation({
|
||||
}
|
||||
}
|
||||
|
||||
// Se já está marcada como lida, retornar sucesso sem fazer nada
|
||||
if (notificacao.lida) {
|
||||
return true;
|
||||
}
|
||||
|
||||
await ctx.db.patch(args.notificacaoId, { lida: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user