salman0ansari / whatsapp-api-nodejs

RESTful WhatsApp API with Multiple Device Support
GNU General Public License v3.0
1.28k stars 610 forks source link

Ninth digit in Brazil #254

Closed JoaoNetoDev closed 2 years ago

JoaoNetoDev commented 2 years ago

Sorry to come back to this topic...

But I followed the instruction received here to look for support at Baileys... There they told me that the isUser function correctly returns the JID, and that the sending is successful through the JID.

But here, I put to return the JID in onWhatsapp and it erroneously brings me with nine on the left in accounts that do not allow this and the sending gives an error consequently.

My knowledge is still too little for me to correct myself... so if you can help me, I'm grateful!

JoaoNetoDev commented 2 years ago

I don't know how to use Baileys functions...

If you can at least guide how I invoke the functions that are on the path "Baileys/src/WABinary/jid-utils.ts", I think I can do the rest...

salman0ansari commented 2 years ago

If you can at least guide how I invoke the functions that are on the path "Baileys/src/WABinary/jid-utils.ts", I think I can do the rest..

https://github.com/salman0ansari/whatsapp-api-nodejs/blob/4a1efc1a27aee41a08b9a8dd40e6a4c36f3d50a1/src/api/helper/mongoAuthState.js#L5

JoaoNetoDev commented 2 years ago

If you can at least guide how I invoke the functions that are on the path "Baileys/src/WABinary/jid-utils.ts", I think I can do the rest..

https://github.com/salman0ansari/whatsapp-api-nodejs/blob/4a1efc1a27aee41a08b9a8dd40e6a4c36f3d50a1/src/api/helper/mongoAuthState.js#L5

@salman0ansari

The difference in results:

"this is": "55849XXXXXXXX@s.whatsapp.net", "must be": [ { "exists": true, "jid": "5584XXXXXXXX@s.whatsapp.net" } ]

Do you think we can push this? Or disagree?

JoaoNetoDev commented 2 years ago

If you can at least guide how I invoke the functions that are on the path "Baileys/src/WABinary/jid-utils.ts", I think I can do the rest..

https://github.com/salman0ansari/whatsapp-api-nodejs/blob/4a1efc1a27aee41a08b9a8dd40e6a4c36f3d50a1/src/api/helper/mongoAuthState.js#L5

@salman0ansari

* It is like this:
  getWhatsAppId(id) {
  if (id.includes('@g.us') || id.includes('@s.whatsapp.net')) return id
  return id.includes('-') ? `${id}@g.us` : `${id}@s.whatsapp.net`
  }

* It should be like this:
  async getWhatsAppId2(id) {
  const jidFull = await this.instance.sock?.onWhatsApp(id)
  return jidFull
  }

The difference in results:

"this is": "55849XXXXXXXX@s.whatsapp.net", "must be": [ { "exists": true, "jid": "5584XXXXXXXX@s.whatsapp.net" } ]

Do you think we can push this? Or disagree?

The onWhatsapp function (present in instance.sock) already returns if the account exists (true or false) and the JID, in the correct way, regardless of the ninth digit or if not allowing it...

If I request this function with the ninth digit, but the JID doesn't have it, it returns with eight... In this case, it shouldn't be requested without the ninth digit, but that's not a problem because the systems in Brazil already work with this new one mobile number format that has already spread across the nation...

I also think this function will operate normally for any country as the function enhances the JID return feature only...