Mark chat as unread after sending message
This commit is contained in:
parent
ed9a8eced9
commit
ffb6638f04
|
|
@ -197,6 +197,15 @@ const handleSendMessage = async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await client.sendMessage(targetJid, message);
|
const response = await client.sendMessage(targetJid, message);
|
||||||
|
|
||||||
|
// Mark the chat as unread so it shows up as a notification/badge on the user's phone
|
||||||
|
try {
|
||||||
|
const chat = await client.getChatById(targetJid);
|
||||||
|
await chat.markUnread();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[WhatsApp Bot] Failed to mark chat as unread:', err);
|
||||||
|
}
|
||||||
|
|
||||||
res.json({ success: true, messageId: response.id._serialized, recipient: targetJid });
|
res.json({ success: true, messageId: response.id._serialized, recipient: targetJid });
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue