Skip to content

Commit

Permalink
fix: Fixed return of sendText for new non contact
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Nov 20, 2020
1 parent 9a05621 commit 4147e75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions src/lib/wapi/functions/send-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,14 @@ export async function sendMessage(to, content) {
} else {
chat = await WAPI.sendExist(to);
const message = content;
if (chat.erro === false || chat.__x_id) {
var ListChat = await Store.Chat.get(to);
var result = await Promise.all(
ListChat ? await chat.sendMessage(message) : ''
);
result = result.join('');
var m = { type: 'sendtext', text: message },
obj,
To = await WAPI.getchatId(chat.id);
if (!chat.erro) {
const result = await chat.sendMessage(message);
if (result === 'success' || result === 'OK') {
obj = WAPI.scope(To, false, result, null);
Object.assign(obj, m);
return obj;
return chat.lastReceivedKey._serialized;
} else {
obj = WAPI.scope(To, true, result, null);
const m = { type: 'sendtext', text: message };
const To = await WAPI.getchatId(chat.id);
const obj = WAPI.scope(To, true, result, null);
Object.assign(obj, m);
return obj;
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/WAPI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ interface WAPI {
longitude: string,
title: string
) => Promise<object>;
sendMessage: (to: string, content: string) => Promise<any>;
sendMessage: (to: string, content: string) => Promise<string>;
sendMessageMentioned: (...args: any) => any;
sendMessageOptions: (
chat: any,
Expand Down

0 comments on commit 4147e75

Please sign in to comment.