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

[BUG][WEBJS] - payload._data.self missing in Webhook body #304

Closed
KKshitiz opened this issue Apr 22, 2024 · 11 comments
Closed

[BUG][WEBJS] - payload._data.self missing in Webhook body #304

KKshitiz opened this issue Apr 22, 2024 · 11 comments
Labels

Comments

@KKshitiz
Copy link

KKshitiz commented Apr 22, 2024

Describe the bug

The message.any event doesn't contain the payload._data.self field which was there earlier

Version

{
  "version":"2024.4.3",
  "engine":"WEBJS",
  "tier":"PLUS",
  "browser":"/usr/bin/google-chrome-stable"
 }

To Reproduce Steps to reproduce the behavior:

  1. Scan the QR code and log in
  2. Send a message from the host device (where WhatsApp app is installed)
  3. Check the payload._data for self field in the message.any event body

Expected behavior

The payload should contain the _data.self field as described in your docs
Message payload

patron:ADVANCED

@KKshitiz KKshitiz added the bug Something isn't working label Apr 22, 2024
@KKshitiz
Copy link
Author

KKshitiz commented Apr 28, 2024

Hi @allburov, any updates on this? It's been a week 😃

patron:ADVANCED

@allburov
Copy link
Contributor

allburov commented Apr 28, 2024

Check the payload._data for self field

What was exactly in that field?

patron:PRO

@allburov
Copy link
Contributor

allburov commented Apr 28, 2024

 "self": "in",

I see, what did you use it for? We've never used that field :D

patron:PRO

@allburov
Copy link
Contributor

allburov commented Apr 28, 2024

I see, there were two possible values - in and out , and it showed the direction of message.any, right?

You can use fromMe for that -

fromMe == true // out
fromMe == false // in

patron:PRO

@KKshitiz
Copy link
Author

KKshitiz commented Apr 29, 2024

Actually, no. Basically, the webhook events for all the sent messages are triggered, even if they are from the host device or any of the linked devices.

This field used to indicate whether the message was sent from the current device which is logged in (WAHA application in this case) and not from any other device.

I used this for integration with our custom messaging systems.

Any idea why the field was removed or if there's an alternative to this?

patron:ADVANCED

@allburov
Copy link
Contributor

allburov commented May 4, 2024

I'm looking at this, weird one.

The fix from app side is to remember which messages you've sent from the session in your database here, kinda reimplementing self logic in application code using database

patron:PRO

@allburov
Copy link
Contributor

allburov commented May 4, 2024

Yep, looks like whatsapp itself don't accept that and implementing it on app side is the only way to solve it :(

The extra options #272 (I thought we could add self: out or another attribute there on out messages from the library to detect them later) doesn't' work - no my_custom_key gets back in the original payload (likely WhatsApp start to cleanup the payload on WhatsApp Web before encrypting it)

patron:PRO

@allburov
Copy link
Contributor

allburov commented May 4, 2024

I've left a comment here #272 (comment)
Would the extra that you can add like this solve your problem?

                "quotedMsg": {
                    "self": "out"
                },

You could check that field and if it's not present - it's likely self: in, not out message.
I'm not sure about the solution stability - it can be changed in WhatsApp Web pretty easily, so we'll have to come up with something new :(
The "external database" approach looks more stable, IMO

I haven't tested it with realy "reply" message yet also

patron:PRO

@KKshitiz
Copy link
Author

KKshitiz commented May 4, 2024

Thanks for the reply @allburov.

As a temporary hack, I've made some changes to our messaging systems but we need a permanent solution.
It'll be great if we can get the "external database" solution working or even the extra field working somehow.

patron:ADVANCED

@allburov
Copy link
Contributor

allburov commented May 6, 2024

be great if we can get the "external database" solution working

I meant YOUR application database :D
So when you're using HTTP API /sendText - you save the message id in the database and then compare it when receiving message.any event.
Sorry for misunderstanding.
It could be added as a part in MongoDB storage tho 🤔 Do you use it?

patron:PRO

@KKshitiz
Copy link
Author

KKshitiz commented May 6, 2024

@allburov Ok cool, thanks a lot for the help

patron:ADVANCED

@KKshitiz KKshitiz closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants