c279706d33
The outbound chat resolver in BlueBubblesAdapter._resolve_chat_guid() matched on participant addresses after the exact chatIdentifier check, which let an outbound DM reply leak into a group thread when the same contact existed in both a 1:1 DM and a group chat: if the group chat was returned earlier by /api/v1/chat/query and the DM's chatIdentifier differed from the bare address, the participant match on the group fired first and returned the group GUID. That GUID was then cached under the bare address, so every subsequent reply went to the wrong chat. Restrict resolution to: 1. raw GUID passthrough 2. exact chatIdentifier / identifier match When no exact match exists the resolver now returns None and the caller already handles that path safely: send() creates a fresh DM via _create_chat_for_handle for address-shaped targets, and _send_attachment fails with a clear "chat not found" error rather than guessing into a group. Adds regression tests under TestBlueBubblesGuidResolution covering: - exact chatIdentifier match still resolves to the DM - participant-only presence does not resolve to the group - the DM is chosen even when the group is returned first - unresolved targets are not cached (no stale-None and no stale-group) Fixes #24157. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>