feat(tctoken): attach tctoken in usync status/about and spam-report IQs - #969
Conversation
Two remaining WA Web privacy-token paths were missing the trusted-contact token, so those requests failed for privacy-restricted accounts: - Usync user-info query: WA Web's USyncStatusProtocol.getUserElement attaches a per-user <tctoken> (gated on profile_scraping_privacy_token_in_about_usync) so a restricted contact's status/about is returned. UserInfoSpec now carries per-user tctokens and get_user_info populates them. - Spam report IQ: WA Web's OutSpamTCTokenMixin attaches the reported contact's <tctoken> (gated on enable_spam_report_iq_with_privacy_token). SpamReportSpec now takes an optional tctoken and send_spam_report resolves it. Both reuse the existing lookup_tc_token_for_jid resolution and are gated by the same AB props WA Web uses. Presence, profile-picture, 1:1 messages and groups already attached the token.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 8 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds optional trusted-contact token support to ChangesTC Token Privacy Feature
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Suggested labels: Look, I need this tctoken flow to work flawlessly — privacy isn't optional, it's the mission. Both SpamReportSpec and UserInfoSpec now carry tokens correctly, gated behind feature flags, tested. That's the kind of disciplined execution I expect. Ship it, but ship it right. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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/features/contacts.rs`:
- Around line 233-252: The per-JID token fetches inside the `get_user_info` flow
are serialized in a `for` loop, which makes bulk contact sync unnecessarily
slow. Refactor the `lookup_tc_token_for_jid` calls to run concurrently using
`futures::join_all` or an equivalent helper, then build the `tc_tokens` map from
the collected results before calling `spec.with_tc_tokens`. Make sure to verify
the `futures` crate (or an existing equivalent) is already available before
changing the `UserInfoSpec` token attachment logic.
🪄 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 (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: fc2dfad7-d853-4932-bd42-077f3e2b6fc5
📒 Files selected for processing (4)
src/features/contacts.rssrc/spam_report.rswacore/src/iq/spam_report.rswacore/src/iq/usync.rs
There was a problem hiding this comment.
3 issues found across 4 files
Confidence score: 3/5
- In
src/features/contacts.rswithinget_user_info, keying the tctoken map by only the JIDusercan mismatch tokens when PN/LID variants share that user part, which can send the wrong per-user token and return incorrect contact data—key and lookup by full JID (including domain) before merging. - Also in
src/features/contacts.rs(get_user_info), the new tctoken lookup loop is sequential, so response time grows roughly one round-trip per contact and can noticeably slow large batches—run lookups concurrently (with an optional concurrency limit) to de-risk latency regressions. - The
std::collections::HashMapqualification insrc/features/contacts.rsis a style-only inconsistency and low merge risk; it can be cleaned up to the existingHashMapimport for readability.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
📦 Binary size report
.text per crate
Baseline: |
Look up per-JID tctokens concurrently in get_user_info instead of sequentially, and key the usync tc_tokens map by the JID's non-ad string form so PN and LID JIDs sharing a user part no longer collide.
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Requires human review: Implements business logic changes to attach tctoken in usync status/about and spam-report IQs. Such protocol changes require human review despite thorough testing.
Re-trigger cubic
Summary
A compliance sweep of the captured WA Web JS for every site that attaches a trusted-contact token found two outgoing requests where the lib omitted it, so they fail for privacy-restricted accounts. This closes both, following the same pattern the merged #966 established for 1:1 messages.
Verified against the captured JS:
WA/Smax/OutSpamTCTokenMixin.js,WA/Smax/OutSpamIndividualReportRequest.js,WAWeb/Usync/Status.js,WAWeb/Get/AboutQueryJob.js,WAWeb/Usync/User.js.1. Usync status/about query — missing per-user
<tctoken>WA Web's
USyncStatusProtocol.getUserElementattaches a per-user<tctoken>to the usync<user>node (gated onprofile_scraping_privacy_token_in_about_usync);getAboutbuilds the status usync viaUSyncUser.withTcToken. Without it, a restricted contact's status/about comes back empty/401.UserInfoSpecnow carriestc_tokens(keyed by the query JID's user part) and attaches<tctoken>to the matching<user>node.get_user_infopopulates them fromlookup_tc_token_for_jid, gated on the same AB prop.2. Spam report IQ — missing
<tctoken>WA Web's spam report (
OutSpamIndividualReportRequest) mergesOutSpamTCTokenMixin(gated onenable_spam_report_iq_with_privacy_token) to attach the reported contact's<tctoken>.SpamReportSpecnow takes an optional tctoken andsend_spam_reportresolves it forrequest.from_jid.Already compliant (unchanged)
1:1 messages (tctoken + cstoken), presence subscribe, profile-picture GET, and group create/participant-add already attach the token. The
ttimestamp attribute is intentionally omitted —tctokenTis never populated anywhere in the captured bundle.Known follow-up (not in this PR)
VoIP call offers: WA Web's
StartCallcallssendTcTokenper participant. The VoIP subsystem doesn't yet issue/attach tctokens (already aTODOinwacore/src/iq/tctoken.rs); left for a dedicated change.Changes
wacore/src/iq/usync.rs:UserInfoSpec::with_tc_tokens; per-user<tctoken>inbuild_iq.wacore/src/iq/spam_report.rs:SpamReportSpec::with_tc_token;<tctoken>child inbuild_iq.src/features/contacts.rs:get_user_inforesolves per-user tctokens under the usync AB prop.src/spam_report.rs:send_spam_reportresolves the reported contact's tctoken under the spam AB prop.Validation
cargo clippy -p wacore -p whatsapp-rust --testsclean;cargo fmt --all --checkclean.cargo test -p wacore --libandcargo test -p whatsapp-rust --lib(909) green.Generated by Claude Code