feat: add inbound username support and USync username protocol#382
feat: add inbound username support and USync username protocol#382
Conversation
Aligns with Baileys upstream PR WhiskeySockets#2480. WhatsApp is rolling out an inbound username field that maps to the user's LID. This change is purely additive — it captures and propagates the new optional field through types, decoders, USync queries, and group/contact events. Skipped intentionally to preserve InfiniteAPI's LID/PN customization: - handleGroupNotification in messages-recv.ts (custom LID->PN flow on groups.upsert / participants.map). Username for these specific events still flows via process-message's emitParticipantsUpdate (reads message.key.participantUsername added in decode-wa-message). Carousel/buttons code (messages.ts, messages-send.ts) untouched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds username propagation and storage across the stack: type updates, message decoding and receipt, contact upserts, group metadata extraction, event payloads, and a new USyncUsernameProtocol with USyncUser username support. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Adds support for WhatsApp’s inbound “username” fields (mapping to LID identity) and introduces a USync query protocol for retrieving usernames, propagating the optional field through decoding, contact/group models, and emitted events.
Changes:
- Extend core types (
Contact,WAMessageKey, group/event payloads) to carry optional usernames. - Decode and propagate inbound username attributes from message stanzas and group metadata.
- Add
USyncUsernameProtocoland extend USync user/query builders to support username-based flows.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/WAUSync/USyncUser.ts | Adds username/usernameKey fields + fluent setters for USync user inputs. |
| src/WAUSync/USyncQuery.ts | Registers USyncUsernameProtocol and exposes withUsernameProtocol(). |
| src/WAUSync/Protocols/index.ts | Re-exports the new username protocol. |
| src/WAUSync/Protocols/USyncUsernameProtocol.ts | New USync protocol to request/parse username results. |
| src/WAUSync/Protocols/USyncContactProtocol.ts | Adds username-based contact query encoding (username/pin/lid). |
| src/Utils/sync-action-utils.ts | Includes username in contacts derived from sync actions. |
| src/Utils/process-message.ts | Emits authorUsername for group participant/update events. |
| src/Utils/history.ts | Includes username on contacts produced from history sync conversations. |
| src/Utils/decode-wa-message.ts | Decodes remoteJidUsername/participantUsername from stanza attrs into WAMessageKey. |
| src/Utils/chat-utils.ts | Includes username for lidContactAction → contacts.upsert. |
| src/Types/Message.ts | Extends WAMessageKey with remoteJidUsername/participantUsername. |
| src/Types/GroupMetadata.ts | Extends group metadata with owner/subject/desc/author username fields. |
| src/Types/Events.ts | Extends group-related event payloads with optional authorUsername. |
| src/Types/Contact.ts | Extends Contact with optional username. |
| src/Socket/messages-recv.ts | Adds participantUsername into notification-derived message keys. |
| src/Socket/groups.ts | Extracts username fields from group metadata and participants list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5351dce3a5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…oundtrip proto.WebMessageInfo.fromObject() rebuilds the key from proto.MessageKey schema, which only declares remoteJid/fromMe/id/participant. Custom Baileys extensions (participantAlt, participantUsername, addressingMode) are silently dropped, so process-message.ts cannot read them downstream and authorUsername/authorPn are lost on group-participants.update, groups.update, and group.join-request events that originate from notifications. Re-attach msg.key after the roundtrip to preserve the custom fields. Addresses Codex P2 review comment on PR #382. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Aligns with Baileys upstream PR WhiskeySockets#2480. WhatsApp is rolling out an inbound username field that maps to the user's LID. This change is purely additive — it captures and propagates the new optional field through types, decoders, USync queries, and group/contact events.
Skipped intentionally to preserve InfiniteAPI's LID/PN customization:
Carousel/buttons code (messages.ts, messages-send.ts) untouched.
Summary by CodeRabbit