-
-
Notifications
You must be signed in to change notification settings - Fork 87
Add reaction and sticker send support #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add reaction and sticker send support #125
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📝 WalkthroughWalkthroughAdds README examples for sticker and reaction usage; introduces Changes
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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ 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. Comment |
There was a problem hiding this 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 conservativelimitInputPixelshelps 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() }
There was a problem hiding this 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.
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
Improvements
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.