Skip to content

Conversation

@ViperTecCorporation
Copy link
Contributor

@ViperTecCorporation ViperTecCorporation commented Jan 24, 2026

Português:
Permite enviar reações a mensagens existentes no WhatsApp informando o message_id e o emoji. Útil para responder sem enviar texto novo; o envio referencia a mensagem original e gera um evento de reação no destinatário.

Permite enviar figurinhas (stickers) via endpoint de mensagens. PNG/JPG/GIF são automaticamente convertidos para WEBP antes do envio, garantindo compatibilidade com o WhatsApp. Basta informar o link da mídia no payload.

English:
Allows sending reactions to existing WhatsApp messages by providing the message_id and an emoji. Useful to respond without sending new text; the reaction references the original message and triggers a reaction event for the recipient.

Allows sending stickers through the messages endpoint. PNG/JPG/GIF are automatically converted to WEBP before sending to ensure WhatsApp compatibility. Just provide the media link in the payload.

Permite enviar figurinhas (stickers) via endpoint de mensagens. PNG/JPG/GIF são automaticamente convertidos para WEBP antes do envio, garantindo compatibilidade com o WhatsApp. Basta informar o link da mídia no payload.

Summary by CodeRabbit

  • New Features

    • Send stickers with automatic on-the-fly WEBP conversion.
    • Send reactions to specific messages (specify target and emoji).
    • Per-recipient send delays are now respected.
  • Improvements

    • Sticker conversion is more robust — failures are logged and sending continues with the original content.
    • Reactions and forwarded/list messages are routed to the correct target; extra send options are preserved.
  • Documentation

    • Added usage examples and sample requests for stickers and reactions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 24, 2026

Warning

Rate limit exceeded

@ViperTecCorporation has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Adds README examples for sticker and reaction usage; introduces convertToWebpSticker utility; integrates sticker conversion and reaction sending into the messaging service with target-aware routing, per-target delays, and propagation of extra send options.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added usage examples for sending stickers (type: sticker) and reactions (type: reaction) with curl payloads and headers.
Sticker Conversion Utility
src/utils/sticker_convert.ts
New convertToWebpSticker(input: Buffer, opts?) that resizes to ≤512×512, encodes to WEBP (quality 80, effort 4), supports animated option, returns Buffer.
Messaging Service
src/services/client_baileys.ts
Added sticker conversion workflow with failure fallback; extended allowed outgoing types to include reaction; implemented reaction flow (resolve original message key via multiple fields/DB, construct reaction content, route to resolved targetTo); refactored forwarding/quoting to use targetTo; introduced per-target delay map; propagated extraSendOptions into final send calls; improved robustness and logging for conversion/lookup failures.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Service as Message Service
    participant ImageUtil as Sticker Converter
    participant Queue as Message Queue

    Client->>Service: POST /send (type: sticker, payload)
    Service->>Service: fetch sticker buffer
    Service->>ImageUtil: convertToWebpSticker(buffer)
    alt Conversion successful
        ImageUtil-->>Service: WEBP buffer
        Service->>Service: set mimetype to image/webp
    else Conversion fails
        ImageUtil-->>Service: Error (logged)
        Service->>Service: continue with original content
    end
    Service->>Service: determine targetTo and apply per-target delay
    Service->>Queue: send/enqueue message to targetTo with extraSendOptions
    Queue-->>Client: delivery result
Loading
sequenceDiagram
    participant Client
    participant Service as Message Service
    participant Store as Message Store
    participant Remote as Remote JID

    Client->>Service: POST /send (type: reaction, payload)
    Service->>Service: extract original message id (various payload fields)
    Service->>Store: lookup original message key
    Store-->>Service: original key (or fallback)
    Service->>Service: build reaction content (emoji + key), determine targetTo
    Service->>Service: apply per-target delay
    Service->>Remote: send reaction to targetTo with extraSendOptions
    Remote-->>Client: reaction ack/delivery
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Poem

🐰 A sticker hops, a little cheer,

WebP wings and emojis near,
Targets tracked with timely leaps,
Options passed while server sleeps,
I nibble code and guard your gear ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add reaction and sticker send support' directly and clearly summarizes the main changes: adding reaction and sticker sending functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/services/client_baileys.ts`:
- Around line 543-551: The sticker download path (where stickerLink is fetched
under the condition involving isWebp and (content as any)?.sticker?.url) buffers
the entire response into memory then converts via convertToWebpSticker, which
can OOM on large inputs; add a MAX_STICKER_BYTES constant and before calling
resp.arrayBuffer() validate resp.headers.get('content-length') (if present)
against the limit and throw a clear error if too large, then after obtaining the
ArrayBuffer check arrayBuffer.byteLength against MAX_STICKER_BYTES and throw if
exceeded; keep using the same AbortSignal timeout (FETCH_TIMEOUT_MS) and ensure
all thrown errors include context like "sticker_too_large" so callers can handle
them.
🧹 Nitpick comments (1)
src/utils/sticker_convert.ts (1)

7-12: Add an input-pixel guard for untrusted images.
Sharp will decode the full image before resize; a conservative limitInputPixels helps prevent memory spikes from oversized inputs.

♻️ Proposed change
 export const convertToWebpSticker = async (input: Buffer, opts: StickerConvertOptions = {}) => {
-  const image = sharp(input, { animated: !!opts.animated })
+  const image = sharp(input, { animated: !!opts.animated, limitInputPixels: 16_777_216 })
   return image
     .resize(512, 512, { fit: 'inside', withoutEnlargement: true })
     .webp({ lossless: !opts.animated, quality: 80, effort: 4 })
     .toBuffer()
 }

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/services/client_baileys.ts`:
- Around line 469-522: The reaction branch resolves a recipient into targetTo
but later response construction still uses the original to, causing
jidToPhoneNumber failures when to is undefined; update all places after the
reaction handling that build success/error responses (and any calls to
jidToPhoneNumber) to use targetTo (fallback to to if targetTo is unset) instead
of to so responses use the resolved recipient; refer to the variables targetTo,
to, reactionKey, content, extraSendOptions when locating the response-building
logic to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant