Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing SendImage method Issue #1165

Open
nadjib-boum opened this issue Jul 30, 2022 · 1 comment
Open

Fixing SendImage method Issue #1165

nadjib-boum opened this issue Jul 30, 2022 · 1 comment

Comments

@nadjib-boum
Copy link

nadjib-boum commented Jul 30, 2022

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.

@erm3nda
Copy link

erm3nda commented Jul 31, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants