diff --git a/newwhats.clube67.com/newwhats.local/backend/src/modules/whatsapp/handlers/MessageHandler.ts b/newwhats.clube67.com/newwhats.local/backend/src/modules/whatsapp/handlers/MessageHandler.ts index 10a0381..b7f3aab 100644 --- a/newwhats.clube67.com/newwhats.local/backend/src/modules/whatsapp/handlers/MessageHandler.ts +++ b/newwhats.clube67.com/newwhats.local/backend/src/modules/whatsapp/handlers/MessageHandler.ts @@ -344,7 +344,7 @@ export class MessageHandler { unreadCount: 0 }, update: { - contactId: contact.id, + contact: { connect: { id: contact.id } }, ...(lastAt && { lastMessageAt: lastAt }) }, }) @@ -595,7 +595,7 @@ export class MessageHandler { lastMessageAt: new Date((messageTimestamp as number) * 1000), }, update: { - contactId: contact.id, // Garante o vínculo (corrige chats órfãos antigos) + contact: { connect: { id: contact.id } }, // Garante o vínculo (corrige chats órfãos antigos) lastMessageAt: new Date((messageTimestamp as number) * 1000), // fromMe: zera unread (estamos respondendo); !fromMe: incrementa unreadCount: fromMe ? { set: 0 } : { increment: 1 },