Skip to content

Fix: Enhance updateProfileStatus with emoji and duration - #2755

Open
ayusc wants to merge 2 commits into
WhiskeySockets:masterfrom
ayusc:patch-2
Open

Fix: Enhance updateProfileStatus with emoji and duration#2755
ayusc wants to merge 2 commits into
WhiskeySockets:masterfrom
ayusc:patch-2

Conversation

@ayusc

@ayusc ayusc commented Aug 6, 2026

Copy link
Copy Markdown

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:mex query. Trims status text to 50 Unicode characters to avoid broken emoji and failed updates.

  • Migration
    • Update calls to updateProfileStatus(status, emoji, duration) where duration is in seconds.
    • Pass an emoji string (e.g., "😊") or an empty string if none.

Written for commit 9a469c7. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Profile status updates now support custom emojis and expiration durations.
    • Status text is limited to 50 characters for improved consistency.
    • Status changes are applied through the updated profile-status experience for more reliable updates.

This commit fixes updateProfileStatus() function to accept emoji and duration parameters as per new whatsapp web changes.
@whiskeysockets-bot

Copy link
Copy Markdown
Contributor

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 works

If you’ve tested this PR, please comment below with:

Tested and working ✅

This helps us speed up the review and merge process.

📦 To test this PR locally:

# NPM
npm install @whiskeysockets/baileys@ayusc/Baileys#patch-2

# Yarn (v2+)
yarn add @whiskeysockets/baileys@ayusc/Baileys#patch-2

# PNPM
pnpm add @whiskeysockets/baileys@ayusc/Baileys#patch-2

If you encounter any issues or have feedback, feel free to comment as well.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

updateProfileStatus now accepts emoji and duration values, limits status text to 50 characters, and sends the data through a WhatsApp MEX get query.

Changes

Profile status update

Layer / File(s) Summary
Status query update
src/Socket/chats.ts
updateProfileStatus now accepts status, emoji, and duration. It truncates status text to 50 characters and sends JSON variables through a WhatsApp MEX get query.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit updates status bright,
With emoji tucked in right.
Fifty characters fit the row,
Duration sets when they go.
The MEX query starts the show.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main changes to updateProfileStatus, including emoji and duration support.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/Socket/chats.ts (1)

386-394: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the opaque WhatsApp protocol contract.

The query_id and 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0af2386 and ab013af.

📒 Files selected for processing (1)
  • src/Socket/chats.ts

Comment thread src/Socket/chats.ts
Comment thread src/Socket/chats.ts
Comment thread src/Socket/chats.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/Socket/chats.ts Outdated
Comment thread src/Socket/chats.ts
attrs: {},
content: Buffer.from(status, 'utf-8')
tag: 'query',
attrs: { query_id: '9152604461510864' },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@ayusc ayusc closed this Aug 8, 2026
@ayusc
ayusc deleted the patch-2 branch August 8, 2026 16:28
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Baileys Review Cycle Aug 8, 2026
@ayusc
ayusc restored the patch-2 branch August 8, 2026 16:29
@ayusc ayusc reopened this Aug 8, 2026
@ayusc

ayusc commented Aug 8, 2026

Copy link
Copy Markdown
Author

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants