mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.03k stars 795 forks source link

Vcard not work #963

Closed jesussales closed 3 years ago

jesussales commented 3 years ago

When i try to send a Vcard return a error in addmsg

Somebody Know how fix it?

jesussales commented 3 years ago

just fix

in neededonbejcts add this { id: "AddAndSendMsgToChat", conditions: (module) => (module.addAndSendMsgToChat) ? module.addAndSendMsgToChat : null },

and change function to

window.WAPI.sendVCard = async function (chatId, vcard) { var chat = Store.Chat.get(chatId); var tempMsg = Object.create(Store.Msg.models.filter(msg => msg.__x_isSentByMe)[0]); var newId = window.WAPI.getNewMessageId(chatId);

var extend = {
    ack     : 0,
    id      : newId,
    local   : !0,
    self    : "out",
    t       : parseInt(new Date().getTime() / 1000),
    to      : chatId,
    isNewMsg: !0,
};

if (Array.isArray(vcard)) {
    Object.assign(extend, {
        type     : "multi_vcard",
        vcardList: vcard
    });

    delete extend.body;
} else {
    Object.assign(extend, {
        type   : "vcard",
        subtype: vcard.displayName,
        body   : vcard.vcard
    });

    delete extend.vcardList;
}

Object.assign(tempMsg, extend);

await Promise.all(Store.AddAndSendMsgToChat(chat, tempMsg))

};

mikelustosa commented 3 years ago

just fix

in neededonbejcts add this { id: "AddAndSendMsgToChat", conditions: (module) => (module.addAndSendMsgToChat) ? module.addAndSendMsgToChat : null },

and change function to

window.WAPI.sendVCard = async function (chatId, vcard) { var chat = Store.Chat.get(chatId); var tempMsg = Object.create(Store.Msg.models.filter(msg => msg.__x_isSentByMe)[0]); var newId = window.WAPI.getNewMessageId(chatId);

var extend = {
    ack     : 0,
    id      : newId,
    local   : !0,
    self    : "out",
    t       : parseInt(new Date().getTime() / 1000),
    to      : chatId,
    isNewMsg: !0,
};

if (Array.isArray(vcard)) {
    Object.assign(extend, {
        type     : "multi_vcard",
        vcardList: vcard
    });

    delete extend.body;
} else {
    Object.assign(extend, {
        type   : "vcard",
        subtype: vcard.displayName,
        body   : vcard.vcard
    });

    delete extend.vcardList;
}

Object.assign(tempMsg, extend);

await Promise.all(Store.AddAndSendMsgToChat(chat, tempMsg))

};

Example of use please?