Skip to content

Commit

Permalink
fix: sendContactVcard
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Jun 22, 2021
1 parent c635644 commit e47ff16
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/lib/wapi/functions/send-contact-vcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,38 @@ MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNMMNNNMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
*/
export async function sendContactVcard(chatId, contact, name) {
var chat = await WAPI.sendExist(chatId);
var cont = await WAPI.sendExist(contact);
const chat = await WAPI.sendExist(chatId);
const cont = await WAPI.sendExist(contact);

if (chat.id && cont.id) {
var newMsgId = await window.WAPI.getNewMessageId(chat.id);
let inChat = await WAPI.getchatId(chatId).catch(() => {});
const newMsgId = await window.WAPI.getNewMessageId(chat.id);
const inChat = await WAPI.getchatId(chatId).catch(() => {});

if (inChat) {
chat.lastReceivedKey._serialized = inChat._serialized;
chat.lastReceivedKey.id = inChat.id;
}
var tempMsg = Object.create(
Store.Msg.models.filter((msg) => msg.__x_isSentByMe && !msg.quotedMsg)[0]
);
var bod = await window.Store.Vcard.vcardFromContactModel(cont.__x_contact);

const fromwWid = await window.Store.Conn.wid;
var body = await window.Store.Vcard.vcardFromContactModel(cont.__x_contact);
name = !name ? cont.__x_formattedTitle : name;
var extend = {
var message = {
id: newMsgId,
ack: 0,
body: bod.vcard,
from: cont.__x_contact,
local: !0,
self: 'out',
body: body.vcard,
from: fromwWid,
self: 'in',
vcardFormattedName: name,
isNewMsg: true,
t: parseInt(new Date().getTime() / 1000),
to: chatId,
to: chat.id,
type: 'vcard',
isNewMsg: !0,
};
Object.assign(tempMsg, extend);
var result =
(await Promise.all(Store.addAndSendMsgToChat(chat, tempMsg)))[1] || '';

const result = (
await Promise.all(window.Store.addAndSendMsgToChat(chat, message))
)[1];

var m = { from: contact, type: 'vcard' };
if (result === 'success' || result === 'OK') {
var obj = WAPI.scope(newMsgId, false, result, null);
Expand Down

6 comments on commit e47ff16

@jonalan7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GustavoPazzini
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code didn't work here

@jonalan7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GustavoPazzini Download the new update

@mikelustosa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GustavoPazzini Download the new update

Would it have the fix for wapi?

@jonalan7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GustavoPazzini Baixe a nova atualização

Teria a correção para wapi?

all functions are separate! We don't have a single file with the functions!

@mikelustosa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GustavoPazzini Baixe a nova atualização

Teria a correção para wapi?

all functions are separate! We don't have a single file with the functions!

Thanks for the answer. It's already been resolved.

Please sign in to comment.