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.02k stars 796 forks source link

javascript error: this._find is not a function #1081

Closed rajeshshettysrs closed 2 years ago

rajeshshettysrs commented 2 years ago

When we try to send messages with attachments like image,pdf..etc for those contacts which are not stored in phone contacts using "window.WAPI.sendImage" function we are getting "javascript error: this._find is not a function" error.

Observations: We are facing this issue may be after chrome updation to V93 version.

Please help

rajeshshettysrs commented 2 years ago

Issue solved:

Solution: window.WAPI.sendImage = function(imgBase64, chatid, filename, caption) { var idUser = new Store.WidFactory.createWid(chatid, { intentionallyUsePrivateConstructor: true }); return Store.FindChat.findChat(idUser).then((chat) => { var mediaBlob = window.WAPI.base64ImageToFile(imgBase64, filename); var mc = new Store.MediaCollection(chat); mc.processAttachments([{file: mediaBlob}, 1], chat, 1).then(() => { let media = mc.models[0]; media.sendToChat(chat, {caption:caption}); return true; }); }); }

and added below code in neededObjects

{ id: "WidFactory", conditions: (module) => (module.isWidlike && module.createWid && module.createWidFromWidLike) ? module : null }, { id: 'FindChat', conditions: (module) => (module && module.findChat) ? module : null},