fix(whatsapp): skip updateLastRoute when dmScope isolates DM sessions#24914
Closed
longevityboris wants to merge 1 commit into
Closed
fix(whatsapp): skip updateLastRoute when dmScope isolates DM sessions#24914longevityboris wants to merge 1 commit into
longevityboris wants to merge 1 commit into
Conversation
When dmScope is per-channel-peer (or per-peer, per-account-channel-peer), WhatsApp DMs get isolated session keys. However, updateLastRoute still unconditionally writes to mainSessionKey, corrupting the main session's delivery context. Gate the call on sessionKey === mainSessionKey. Fixes #24912 Related: #13580
Contributor
|
AI-assisted stale triage closure (fix-only duplicate sweep). This PR overlaps with #24949 for #24912 (WhatsApp dmScope updateLastRoute isolation). #24949 is the active path for this fix scope. Closing this duplicate as AI-closed. Reopen guidance:
|
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.
Summary
dmScopeis set toper-channel-peer(orper-peer,per-account-channel-peer), WhatsApp DM sessions receive isolated session keys that differ frommainSessionKey.updateLastRouteInBackgroundwas unconditionally called withmainSessionKeyfor all DM routes, corrupting the main session's delivery context with the isolated DM's routing info.updateLastRouteInBackgroundcall onparams.route.sessionKey === params.route.mainSessionKey, so it only fires when the DM session is not isolated bydmScope.This is the same fix pattern as PR #13580 (Telegram), now applied to WhatsApp.
Fixes #24912
Related: #13580
Changes
src/web/auto-reply/monitor/process-message.ts: Addedparams.route.sessionKey === params.route.mainSessionKeyguard to theupdateLastRouteInBackgroundcall for DM routes.src/web/auto-reply/monitor/process-message.inbound-contract.test.ts: Added two test cases verifying thatupdateLastRouteInBackgroundis called whensessionKey === mainSessionKeyand skipped when they differ (dmScope isolation).Test plan
vitest run src/web/auto-reply/monitor/process-message.inbound-contract.test.ts)calls updateLastRouteInBackground for DMs when sessionKey equals mainSessionKey(no dmScope isolation - existing behavior preserved)skips updateLastRouteInBackground for DMs when dmScope isolates session key(dmScope active - bug fix verified)dmScope: per-channel-peeron a WhatsApp account, send DMs from different peers, verify the main session's last-route is not overwritten🤖 Generated with Claude Code
Greptile Summary
Fixes session corruption bug in WhatsApp DM routing when
dmScopeisolation is active. WhendmScopeis configured (e.g.,per-channel-peer), isolated DM sessions receive different session keys from the main session, but the code was unconditionally callingupdateLastRouteInBackgroundwithmainSessionKeyfor all DMs, overwriting the main session's delivery context with isolated session routing data.sessionKey === mainSessionKeybefore updating last route for DMsConfidence Score: 5/5
Last reviewed commit: 67ba9d6
(2/5) Greptile learns from your feedback when you react with thumbs up/down!