So I'm creating a chrome extension to automate message sending.
I used the sendImage method
`window.WAPI.sendImage = function (imgBase64, chatid, filename, caption, done) {
//var idUser = new window.Store.UserConstructor(chatid);
var idUser = new window.Store.UserConstructor(chatid, { intentionallyUsePrivateConstructor: true });
// create new chat
return Store.Chat.find(idUser).then((chat) => {
var mediaBlob = window.WAPI.base64ImageToFile(imgBase64, filename);
var mc = new Store.MediaCollection(chat);
mc.processAttachments([{file: mediaBlob}, 1], chat, 1).then(() => {
var media = mc.models[0];
media.sendToChat(chat, { caption: caption });
if (done !== undefined) done(true);
});
});
}
`
But It did not work, So what I did is changing:
var media = mc.models[0];
with :
var media = mc._models[0];
And It did Work!
So in case someone is running into this problem, try this solution.
This happened few days ago with getUnreadMessages, had to prepend "_" to chat models.
Happily this time is easy to fix again, thank you. Fixed and working again.
So I'm creating a chrome extension to automate message sending. I used the sendImage method `window.WAPI.sendImage = function (imgBase64, chatid, filename, caption, done) {
} ` But It did not work, So what I did is changing: var media = mc.models[0]; with : var media = mc._models[0];
And It did Work! So in case someone is running into this problem, try this solution.