wppconnect-team / wppconnect

WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination
https://wppconnect.io
Other
1.92k stars 337 forks source link

fix: ID type definition of Contact model #2285

Closed gekkedev closed 3 months ago

gekkedev commented 3 months ago

From what I observed, this is a string (serialized format, user@server). If there are exceptions where it is actually a WID object, let me know and I'll adapt this PR.

devactivity-app[bot] commented 3 months ago

Pull Request Summary by devActivity

Metrics

Cycle Time: 14d 1h 42m

Achievements

gekkedev commented 1 month ago

I might have been wrong on this: client.getMessages(chatId) returns messages where the sender attribute is a Contact object. The attribute id is a WID, not a serialized string. In wa-js this is also defined as WID: https://github.com/wppconnect-team/wa-js/blob/4df7fee17ed071b461e2da28d8e6c9e7592c9739/src/whatsapp/models/ContactModel.ts#L28 However, I'm pretty sure I had a use case where it was a serialized string (need to find out when exactly for reproduction). It could be, that the type of id depends on which methods we use to get a Contact object. 🤔

@icleitoncosta what is the desired state here?

  1. A union type for both possibilities? string | WID
  2. wa-js deserializing if necessary to always provide a WID
  3. wa-js serializing if necessary to always provide a string