Skip to content

Commit

Permalink
Wapi.js changed
Browse files Browse the repository at this point in the history
function sendMessageToId updated, Just checks now if callback done exists
  • Loading branch information
daniel-scatigno authored Dec 24, 2019
1 parent fde4a85 commit 626f276
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions webwhatsapi/js/wapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,20 +725,26 @@ 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);
if (done !== undefined)
done(true);
return true;
} else {
Store.Chat.find(contact.jid).then(chat => {
chat.sendMessage(message);
if (done !== undefined)
done(true);
return true;
}).catch(reject => {
if (WAPI.sendMessage(id, message)) {
done(true);
if (done !== undefined)
done(true);
return true;
} else {
done(false);
if (done !== undefined)
done(false);
return false;
}
});
Expand All @@ -765,7 +771,7 @@ window.WAPI.sendMessageToID = function (id, message, done) {
}
if (done !== undefined) done(false);
return false;
}
};

window.WAPI.sendMessage = function (id, message, done) {
var chat = WAPI.getChat(id);
Expand Down

0 comments on commit 626f276

Please sign in to comment.