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

Contact model id is sometimes serialized, sometimes a Wid object #2361

Open
gekkedev opened this issue Oct 2, 2024 · 0 comments
Open

Contact model id is sometimes serialized, sometimes a Wid object #2361

gekkedev opened this issue Oct 2, 2024 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@gekkedev
Copy link
Contributor

gekkedev commented Oct 2, 2024

Description

As stated in the tile, the Contact model's id attribute is sometimes a Wid and sometimes a string. I thought I had corrected this in #2285 but changed it from one possible type to another.

Example`s

  client.onMessage(async (message: Message) => {
    //.sender.id is a serialized string
  }
  await client.getMessageById("user@server")
  //.sender.id is an object

To cover up the symptoms I can offer to create a PR that changes the type definition to allow both. Still unclear to me: when exactly to expect which type.
As a result, everyone using WPPConnect has to address this in their code if they want type safety. However, why does this happen in the first place? Is it possible that WA-JS sometimes serializes/deserializes when it shouldn't?

@gekkedev gekkedev added bug Something isn't working needs triage labels Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant