I am using a WhatsApp function to send an automated message, the message is sent, but it remains pending and does not reach the recipient.
Code:
window.WAID.sendChatMessage = async function(ch, body) {
var chat = ch.id ? ch : window.WAID.Store.Chat.get(ch);
var chatId = chat.id._serialized;
var msgIveSent = chat.msgs.filter(msg => msg.__x_isSentByMe)[0];
if(!msgIveSent) return chat.sendMessage(body);
var tempMsg = Object.create(msgIveSent);
var newId = window.WAID.getNewMessageId(chatId);
var extend = (0, o.Z)({
id: newId,
ack: 0,
local: !0,
from: window.WAIDS.Store.WAIDUser.getMaybeMeUser(),
to: ch.id,
local: !0,
self: "out",
t: parseInt(new Date().getTime() / 1000),
isNewMsg: !0,
type: "chat",
}, body);
console.log(chat, tempMsg, extend)
Object.assign(tempMsg, extend);
const res = await Promise.all(window.WAIDS.Store.addAndSendMsgToChat(tempMsg, extend))
return newId._serialized;
}
addAndSendMsgToChat is a native WhatsApp feature
TypeError: e.isLid is not a function
at t.findChatActionLog (app.208e5a49d844a8c35245.js:40:229672)
at app.208e5a49d844a8c35245.js:40:313277
at t.promiseCallSync (app.208e5a49d844a8c35245.js:40:104856)
at app.208e5a49d844a8c35245.js:40:313200
at Generator.next (<anonymous>)
at t (vendor1~app.0c8e960e5dfd7020f562.js:2:66483)
at s (vendor1~app.0c8e960e5dfd7020f562.js:2:66694)
at vendor1~app.0c8e960e5dfd7020f562.js:2:66753
at Y (app.208e5a49d844a8c35245.js:5:140300)
at new y (app.208e5a49d844a8c35245.js:5:132867)
I expected the message to be sent and received by the recipient