fix: nest profile picture tctoken and avoid usync on lookup#2614
fix: nest profile picture tctoken and avoid usync on lookup#2614gusquadri wants to merge 3 commits into
Conversation
|
Thanks for opening this pull request and contributing to the project! The next step is for the maintainers to review your changes. If everything looks good, it will be approved and merged into the main branch. In the meantime, anyone in the community is encouraged to test this pull request and provide feedback. ✅ How to confirm it worksIf you’ve tested this PR, please comment below with: This helps us speed up the review and merge process. 📦 To test this PR locally:If you encounter any issues or have feedback, feel free to comment as well. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds LIDMappingStore.getKnownLIDForPN for single-PN LID resolution (validation, cache check, targeted DB fetch, and cache update) and wires it into makeChatsSocket; profilePictureUrl is refactored to build the picture node up front and use the resolver when creating WhatsApp tctoken payloads. ChangesPN-to-LID Resolver Integration
Sequence DiagramsequenceDiagram
participant profilePictureUrl as profilePictureUrl
participant LIDMappingStore
participant Cache as pn:/lid: Cache
participant DB as lid-mapping DB
participant tctoken as buildTcTokenFromJid
profilePictureUrl->>LIDMappingStore: getKnownLIDForPN(pn)
LIDMappingStore->>LIDMappingStore: validate & decode PN
LIDMappingStore->>Cache: check pn:<user> mapping
alt cache hit
Cache-->>LIDMappingStore: cached lid:<user>
else cache miss
LIDMappingStore->>DB: fetch lid-mapping for PN user
DB-->>LIDMappingStore: mapping result
LIDMappingStore->>Cache: update pn: & lid: caches
end
LIDMappingStore-->>profilePictureUrl: formatted LID JID
profilePictureUrl->>tctoken: buildTcTokenFromJid(jid, getKnownLIDForPN)
tctoken-->>profilePictureUrl: token nodes
profilePictureUrl->>profilePictureUrl: assign to pictureNode.content
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Signal/lid-mapping.ts`:
- Around line 121-126: The code reads stored = await
this.keys.get('lid-mapping', [pnUser]) and unguardedly sets lidUser =
stored[pnUser] then caches and formats it; if stored[pnUser] is non-string we
may cache invalid JIDs. Update the block that handles the result from keys.get
(the stored variable and lidUser) to check typeof lidUser === 'string' before
calling this.mappingCache.set(`pn:${pnUser}`, lidUser) or
this.mappingCache.set(`lid:${lidUser}`, pnUser) and before using lidUser for any
JID formatting—mirror the same guard used in getLIDsForPNs to bail out or skip
caching when lidUser is not a string.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 517a657d-8490-4c0b-b8f6-d89f9d171f80
📒 Files selected for processing (2)
src/Signal/lid-mapping.tssrc/Socket/chats.ts
tctokeninside the<picture>node, matching WA Web and whatsmeowSummary by cubic
Nest the profile-picture tctoken inside the
<picture>node and avoid PN→LID USync when only fetching a profile photo URL. Matches WA Web/whatsmeowbehavior and reduces potential ban risk.<picture>in profile picture URL queries.getKnownLIDForPN(cached PN→LID, no USync) to build the tctoken; accept only non-empty stored LIDs and attach the token only when the mapping is locally known.Written for commit 2d91a47. Summary will update on new commits.
Summary by CodeRabbit
New Features
Refactor