Open mhndm opened 3 years ago
@mhndm
I think you must search the wapi.js
file for this line :
Store.Chat.find(contact.jid).then(chat => {
Then preceed it by this code
if(typeof contact.jid === 'undefined')
{
contact.jid = {
'_serialized' : id,
'server' : '@' + id.split('@')[1],
'user' : id.split('@')[0]
}
}
It seems that the contact
returned from getContact
function is no longer contains jid
property for groups, so we must do a work around for that and provide our own jid 👍
The final form of this part of code will look like this :
.
.
.
if(typeof contact.jid === 'undefined')
{
contact.jid = {
'_serialized' : id,
'server' : '@' + id.split('@')[1],
'user' : id.split('@')[0]
}
}
Store.Chat.find(contact.jid).then(chat => {
chat.sendMessage(message);
return true;
}).catch(reject => {
if (WAPI.sendMessage(id, message)) {
done(true);
return true;
}else{
done(false);
return false;
}
});
}
.
.
.
I hope that this solve your problem at least for now 👯
@mhndm
I think you must search the
wapi.js
file for this line :Store.Chat.find(contact.jid).then(chat => {
Then preceed it by this code
if(typeof contact.jid === 'undefined') { contact.jid = { '_serialized' : id, 'server' : '@' + id.split('@')[1], 'user' : id.split('@')[0] } }
It seems that the
contact
returned fromgetContact
function is no longer containsjid
property for groups, so we must do a work around for that and provide our own jid 👍The final form of this part of code will look like this :
. . . if(typeof contact.jid === 'undefined') { contact.jid = { '_serialized' : id, 'server' : '@' + id.split('@')[1], 'user' : id.split('@')[0] } } Store.Chat.find(contact.jid).then(chat => { chat.sendMessage(message); return true; }).catch(reject => { if (WAPI.sendMessage(id, message)) { done(true); return true; }else{ done(false); return false; } }); } . . .
I hope that this solve your problem at least for now 👯
how exactly?
window.WAPI.sendMessageToID = function (id, message, done) { try { window.getContact = (id) => { return Store.WapQuery.queryExist(id); } window.getContact(id).then(contact => { if (contact.status === 404) { done(true); } else { Store.Chat.find(contact.jid).then(chat => { chat.sendMessage(message); return true; }).catch(reject => { if (WAPI.sendMessage(id, message)) { done(true); return true; }else{ done(false); return false; } }); } });
@oltanalkan
This workaround is working for me till now.
window.WAPI.sendMessageToID = function (id, message, done) {
try {
window.getContact = (id) => {
return Store.WapQuery.queryExist(id);
}
window.getContact(id).then(contact => {
if (contact.status === 404) {
done(true);
} else {
if(typeof contact.jid === 'undefined') {
contact.jid = {
'_serialized' : id,
'server' : '@' + id.split('@')[1],
'user' : id.split('@')[0]
}
}
Store.Chat.find(contact.jid).then(chat => {
chat.sendMessage(message);
return true;
}).catch(reject => {
if (WAPI.sendMessage(id, message)) {
done(true);
return true;
}else{
done(false);
return false;
}
});
}
});
} catch (e) {
if (window.Store.Chat.length === 0)
return false;
firstChat = Store.Chat.models[0];
var originalID = firstChat.id;
firstChat.id = typeof originalID === "string" ? id : new window.Store.UserConstructor(id, { intentionallyUsePrivateConstructor: true });
if (done !== undefined) {
firstChat.sendMessage(message).then(function () {
firstChat.id = originalID;
done(true);
});
return true;
} else {
firstChat.sendMessage(message);
firstChat.id = originalID;
return true;
}
}
if (done !== undefined) done(false);
return false;
}
this is new issue the api send media to groups but not text its send both images and text to private numbers