commit 68898e03914d97491efb0188468446433f444aa1
parent 5e9a737e46918ddf1593faf04961b410404b0364
Author: AMIT DUTTA <amitdutta4255@gmail.com>
Date: Mon, 16 Feb 2026 19:26:23 +0530
Store phone number in chat and message documents
Added phone number extraction and storage to chat and message.
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/index.js b/index.js
@@ -110,12 +110,14 @@ async function startWhatsApp() {
const isFromMe = msg.key.fromMe || false;
const senderName = isFromMe ? "Me" : (msg.pushName || "Unknown");
+ const phoneNumber = remoteJid.split('@')[0]; // Extract number from JID
// --- FIX: Create/Update Parent Chat Document ---
// This makes the chat visible in the list automatically
await db.collection('Chats').doc(remoteJid).set({
lastActive: timestamp,
displayName: senderName,
+ phoneNumber: phoneNumber, // Added: Save phone number/ID to Chat
id: remoteJid
}, { merge: true });
@@ -128,6 +130,7 @@ async function startWhatsApp() {
text: textContent,
senderId: remoteJid,
senderName: senderName,
+ senderPhoneNumber: phoneNumber, // Added: Save phone number/ID to Message
timestamp: timestamp,
fromMe: isFromMe,
id: msg.key.id