fix(bluebubbles): extract chatGuid from chats array in webhook payload#8295
Open
BukeLy wants to merge 2 commits intoNousResearch:mainfrom
Open
fix(bluebubbles): extract chatGuid from chats array in webhook payload#8295BukeLy wants to merge 2 commits intoNousResearch:mainfrom
BukeLy wants to merge 2 commits intoNousResearch:mainfrom
Conversation
BlueBubbles webhook payloads do not populate the top-level `chatGuid`
field on message records. The chat GUID is only available inside the
`chats` array (e.g. `record["chats"][0]["guid"]`).
Without the correct chatGuid, the adapter falls back to the sender's
phone number as the session chat ID. When the same contact exists in
both a DM and a group chat, `_resolve_chat_guid` may resolve the
phone number to the wrong conversation, causing DM replies to land
in the group or vice versa.
Now fall back to `chats[0].guid` when direct chatGuid fields are
empty. Also removes the stale `payload.get("guid")` fallback which
incorrectly matched the message GUID (not chat GUID).
9105f61 to
2a676ec
Compare
1 task
Test extraction of chat GUID from the chats[] array when top-level chatGuid fields are null (common in BB webhook payloads). Covers DM, group, direct-field priority, empty array, and missing key cases.
19 tasks
Author
|
Hi @jbarket @chalkers @leon @intertwine, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
BlueBubbles webhook payloads do not populate the top-level
chatGuidorchatIdentifierfields on message records. The chat GUID is only available inside thechatsarray. Without the correct chatGuid, the adapter falls back to the sender's phone number, and_resolve_chat_guidmay resolve it to a group chat where the contact is a participant — causing DM replies to go to the wrong chat.This PR falls back to
record["chats"][0]["guid"]when directchatGuidfields are empty, and removes the stalepayload.get("guid")fallback that incorrectly matched the message GUID.Related Issue
Fixes #8514
Type of Change
Changes Made
gateway/platforms/bluebubbles.py: Addedchats[0].guidfallback, removed incorrectpayload.get("guid")fallbacktests/gateway/test_bluebubbles.py: AddedTestBlueBubblesChatGuidFromChatsArray(5 tests)How to Test
Checklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping