Fix: Enhance updateProfileStatus with emoji and duration - #2755
Conversation
This commit fixes updateProfileStatus() function to accept emoji and duration parameters as per new whatsapp web changes.
|
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. |
📝 WalkthroughWalkthrough
ChangesProfile status update
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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: 3
🧹 Nitpick comments (1)
src/Socket/chats.ts (1)
386-394: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the opaque WhatsApp protocol contract.
The
query_idand JSON field names are server-specific. Add a why-comment or move them into a named payload builder. Explain that this shape must remain aligned with the current WhatsApp Web timed profile-status protocol.Proposed comment
{ tag: 'query', attrs: { query_id: '9152604461510864' }, + // Keep this query ID and payload shape aligned with WhatsApp Web's timed profile-status protocol. content: Buffer.from(As per coding guidelines, comments must explain the why for protocol quirks, WhatsApp-side behavior, and non-obvious workarounds.
🤖 Prompt for 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. In `@src/Socket/chats.ts` around lines 386 - 394, Document the protocol-specific payload near the `query_id` and JSON fields in the surrounding status-send logic. Add a concise why-comment explaining that the opaque query ID and field shape must remain aligned with WhatsApp Web’s current timed profile-status protocol, or extract them into a named payload builder that carries this explanation.Source: Coding guidelines
🤖 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/Socket/chats.ts`:
- Around line 376-402: Add an integration test for the exported
updateProfileStatus function in chats.test.ts that mocks the binary-node
transport and verifies the w:mex IQ attributes, query_id, decoded
variables.input values, emoji, ephemeral duration, and truncation of status text
to 50 characters.
- Line 376: Preserve backward compatibility in updateProfileStatus by making
emoji and duration optional and retaining the existing status-only behavior,
including valid payload construction when they are omitted; alternatively,
explicitly mark and update the public API change exposed by makeChatsSocket for
all callers.
- Line 392: Update the status truncation expression in the chat payload to limit
by Unicode code points rather than UTF-16 code units, ensuring the 50-character
boundary cannot split a supplementary character while preserving the existing
maximum length.
---
Nitpick comments:
In `@src/Socket/chats.ts`:
- Around line 386-394: Document the protocol-specific payload near the
`query_id` and JSON fields in the surrounding status-send logic. Add a concise
why-comment explaining that the opaque query ID and field shape must remain
aligned with WhatsApp Web’s current timed profile-status protocol, or extract
them into a named payload builder that carries this explanation.
🪄 Autofix
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 Plus
Run ID: e4210921-7072-49bc-ba41-0eb131e6e858
📒 Files selected for processing (1)
src/Socket/chats.ts
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/Socket/chats.ts">
<violation number="1" location="src/Socket/chats.ts:387">
P3: There's no test coverage for the new updateProfileStatus IQ payload structure (query_id, JSON variables, emoji, ephemeral_duration_sec, and the 50-character text truncation). Consider adding an integration test that mocks the binary-node transport and asserts these fields.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| attrs: {}, | ||
| content: Buffer.from(status, 'utf-8') | ||
| tag: 'query', | ||
| attrs: { query_id: '9152604461510864' }, |
There was a problem hiding this comment.
P3: There's no test coverage for the new updateProfileStatus IQ payload structure (query_id, JSON variables, emoji, ephemeral_duration_sec, and the 50-character text truncation). Consider adding an integration test that mocks the binary-node transport and asserts these fields.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/Socket/chats.ts, line 387:
<comment>There's no test coverage for the new updateProfileStatus IQ payload structure (query_id, JSON variables, emoji, ephemeral_duration_sec, and the 50-character text truncation). Consider adding an integration test that mocks the binary-node transport and asserts these fields.</comment>
<file context>
@@ -373,24 +373,35 @@ export const makeChatsSocket = (config: SocketConfig) => {
- attrs: {},
- content: Buffer.from(status, 'utf-8')
+ tag: 'query',
+ attrs: { query_id: '9152604461510864' },
+ content: Buffer.from(
+ JSON.stringify({
</file context>
|
Tested and working ✅ |
status.slice(0, 50) counts UTF-16 code units. If the 50th unit is a high surrogate, the payload receives a truncated supplementary character as \ud83d and WhatsApp rejects it. Slice or validate the status by Unicode code points instead.
This commit fixes updateProfileStatus() function to accept emoji and duration parameters as per new whatsapp web changes.
Summary by cubic
Updated updateProfileStatus to accept emoji and duration and to use the new WhatsApp Web
w:mexquery. Trims status text to 50 Unicode characters to avoid broken emoji and failed updates.updateProfileStatus(status, emoji, duration)wheredurationis in seconds.Written for commit 9a469c7. Summary will update on new commits.
Summary by CodeRabbit