mimamch / wa-multi-session

Multiple Session Whatsapp Socket Javascript Library
https://www.npmjs.com/package/wa-multi-session
MIT License
114 stars 37 forks source link

onMessageReceived from iphone users #7

Closed MateoMax-hub closed 11 months ago

MateoMax-hub commented 1 year ago

hi i was making a simple app to responde msg automatically and notice that when an iphone user sends me a msg i don't receive the content of the message anywhere, this is the code whatsapp.onMessageReceived(async (msg) => { console.log(New Message =>, msg);

and this is the log from iphone users New Message => { key: { remoteJid: ****@s.whatsapp.net', fromMe: false, id: '****', participant: undefined }, messageTimestamp: 1689286004, pushName: '****', broadcast: false, messageStubType: 2, messageStubParameters: [ 'Bad MAC' ], sessionId: 'qeso', saveImage: [Function (anonymous)], saveVideo: [Function (anonymous)], saveDocument: [Function (anonymous)] } i replaced some private data with "****" am i doing something wrong? is this fixeable? thanks in advance

with not iphone users i found the content of the message in msg.message.conversation

if the iphone user send a msg on a gruop chat im able to see the content but not on private chats

ex of the log when iphone user send msg on a group

New Message => { key: { remoteJid: '****@g.us', fromMe: false, id: '****', participant: '****@s.whatsapp.net' }, messageTimestamp: 1689286637, pushName: '****', broadcast: false, message: Message { senderKeyDistributionMessage: SenderKeyDistributionMessage { groupId: '****@g.us', axolotlSenderKeyDistributionMessage: [Uint8Array] }, extendedTextMessage: ExtendedTextMessage { text: 'TEXT HERE', contextInfo: [ContextInfo] }, messageContextInfo: MessageContextInfo { deviceListMetadata: [DeviceListMetadata], deviceListMetadataVersion: 2 } }, sessionId: 'qeso', saveImage: [Function (anonymous)], saveVideo: [Function (anonymous)], saveDocument: [Function (anonymous)] }

mimamch commented 1 year ago

I never know there an issue with message from iphone device, but let's check it out

Caption for message will different sometimes so I create this function to parsing it from msg object:

const getMessageCaption = (msg: wa.MessageReceived): string => { return ( msg.message?.conversation || msg.message?.imageMessage?.caption || msg.message?.videoMessage?.caption || msg.message?.documentMessage?.caption || msg.message?.extendedTextMessage?.text || "" ); };

MateoMax-hub commented 1 year ago

if you need more context of my code to reproduce the bug let me know, i'm very interested in this library and it's potential, i will try using that parser and see if something change

MateoMax-hub commented 1 year ago

i just saw that today i'm receiving the msg from iphone users as expected, i don't see any reason for a change... i don't update anything in my code since my last comment here

mimamch commented 1 year ago

Some spesific case may cause some unknown bug 💨

MateoMax-hub commented 11 months ago

i'm srry i don't know if the correct thing to do is open a new issue or just ask here,

i need an instance where i can see when i put a label on a chat in whatsapp business, if it's not created i will try make one based on your repository for personal use, if you want too i will create a pull request so you can add that feature here too, let me know if there is any function to achieve my goal @mimamch

MateoMax-hub commented 11 months ago

i already confirm that in the socket/index.js file you start a socket a receive every event that occurs in the session, and also when labels are assigned to chats so i can make a listener for that specific event, i will clone or fork the repository to make the changes i need for my personal use, let me know if you want me to make pull request of that feature to add it to your project

mimamch commented 11 months ago

That's great, currently we are do not have that feature.

Maybe you can use this reference to creating labels feature https://github.com/WhiskeySockets/Baileys/pull/69