feat: enhance vacation management system with new employee association functionality, improved email notification handling, and comprehensive documentation; update dependencies and UI components for better user experience
This commit is contained in:
@@ -187,6 +187,7 @@ export const enviarMensagem = mutation({
|
||||
arquivoTamanho: v.optional(v.number()),
|
||||
arquivoTipo: v.optional(v.string()),
|
||||
mencoes: v.optional(v.array(v.id("usuarios"))),
|
||||
permitirNotificacaoParaSiMesmo: v.optional(v.boolean()), // ✅ NOVO: Permite criar notificação para si mesmo
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const usuarioAtual = await getUsuarioAutenticado(ctx);
|
||||
@@ -219,10 +220,14 @@ export const enviarMensagem = mutation({
|
||||
ultimaMensagemTimestamp: Date.now(),
|
||||
});
|
||||
|
||||
// Criar notificações para outros participantes (com tratamento de erro)
|
||||
// Criar notificações para participantes (com tratamento de erro)
|
||||
try {
|
||||
for (const participanteId of conversa.participantes) {
|
||||
if (participanteId !== usuarioAtual._id) {
|
||||
// ✅ MODIFICADO: Permite notificação para si mesmo se flag estiver ativa
|
||||
const ehOMesmoUsuario = participanteId === usuarioAtual._id;
|
||||
const deveCriarNotificacao = !ehOMesmoUsuario || args.permitirNotificacaoParaSiMesmo;
|
||||
|
||||
if (deveCriarNotificacao) {
|
||||
const tipoNotificacao = args.mencoes?.includes(participanteId)
|
||||
? "mencao"
|
||||
: "nova_mensagem";
|
||||
@@ -593,15 +598,20 @@ export const listarConversas = query({
|
||||
if (conversa.tipo === "individual") {
|
||||
const outroUsuarioRaw = participantes.find((p) => p?._id !== usuarioAtual._id);
|
||||
if (outroUsuarioRaw) {
|
||||
// Adicionar URL da foto de perfil
|
||||
let fotoPerfilUrl = null;
|
||||
if (outroUsuarioRaw.fotoPerfil) {
|
||||
fotoPerfilUrl = await ctx.storage.getUrl(outroUsuarioRaw.fotoPerfil);
|
||||
// 🔄 BUSCAR DADOS ATUALIZADOS DO USUÁRIO (não usar snapshot)
|
||||
const usuarioAtualizado = await ctx.db.get(outroUsuarioRaw._id);
|
||||
|
||||
if (usuarioAtualizado) {
|
||||
// Adicionar URL da foto de perfil
|
||||
let fotoPerfilUrl = null;
|
||||
if (usuarioAtualizado.fotoPerfil) {
|
||||
fotoPerfilUrl = await ctx.storage.getUrl(usuarioAtualizado.fotoPerfil);
|
||||
}
|
||||
outroUsuario = {
|
||||
...usuarioAtualizado,
|
||||
fotoPerfilUrl,
|
||||
};
|
||||
}
|
||||
outroUsuario = {
|
||||
...outroUsuarioRaw,
|
||||
fotoPerfilUrl,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user