Conversation
|
Warning Rate limit exceeded@9cb14c1ec0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 28 seconds before requesting another review. ⌛ 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. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds build and cache optimizations (npm scripts, webpack filesystem caches, TypeScript incremental tsBuildInfo files) and refactors many async code paths across API layers and initializer to use async/await and throw-based error propagation instead of Promise constructor patterns. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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: 6
🧹 Nitpick comments (6)
src/api/layers/group.layer.ts (1)
72-74: Consider using strict equality for error checks.Using
==instead of===works here but is inconsistent with TypeScript best practices. This pattern appears in multiple methods (setGroupSettings,setGroupTitle,setGroupDescription,getGroupMembers,getGroupAdmins).🔎 Proposed fix
- if (result['erro'] == true) { + if (result['erro'] === true) { throw result; }src/api/layers/controls.layer.ts (1)
200-200: Inconsistent equality operator.Line 200 uses strict equality (
===) to checkresult['erro'], while other similar checks in this file (lines 67, 100) and across other layers use loose equality (==). For consistency, align with the pattern used elsewhere.🔎 Suggested fix for consistency
- if (result['erro'] === true) { + if (result['erro'] == true) {src/api/layers/retriever.layer.ts (1)
132-137: Clarify the await pattern for consistency.Lines 134-135 assign the Promise without awaiting, then await in the return statement:
let chats = WAPI.getAllChats(); return (await chats).filter(...). This is functionally correct but less clear than the pattern used at line 123 ingetAllChatsNewMsg, which awaits immediately:let chats = await WAPI.getAllChats();.Apply the same pattern at lines 204-205 in
getAllChatsTransmissionfor consistency.🔎 Suggested refactor for clarity
public async getAllChatsContacts() { return await this.page.evaluate(async () => { - let chats = WAPI.getAllChats(); - return (await chats).filter((chat) => chat.kind === 'chat'); + let chats = await WAPI.getAllChats(); + return chats.filter((chat) => chat.kind === 'chat'); }); }Apply the same pattern to
getAllChatsTransmission(lines 202-207):public async getAllChatsTransmission() { return await this.page.evaluate(async () => { - let chats = WAPI.getAllChats(); - return (await chats).filter((chat) => chat.kind === 'broadcast'); + let chats = await WAPI.getAllChats(); + return chats.filter((chat) => chat.kind === 'broadcast'); }); }src/api/layers/sender.layer.ts (2)
753-758: Logic error: Condition allows sending with any MIME type.The condition on lines 753-758 uses
||which means it will proceed if!mimeTypeis true (but this case already throws at line 745-751) OR if the mimeType matches audio types. However, any non-audio mimeType that exists will still reach the else branch correctly.Wait—re-analyzing: if
mimeTypeis truthy but NOT audio, the condition is false, so the else branch (lines 769-775) correctly throws. The!mimeTypecheck is redundant since we already threw for falsy mimeType above.🔎 Suggested simplification (optional)
- if ( - !mimeType || - mimeType.includes('audio/mpeg') || - mimeType.includes('audio/mp3') || - mimeType.includes('audio/ogg') - ) { + if ( + mimeType.includes('audio/mpeg') || + mimeType.includes('audio/mp3') || + mimeType.includes('audio/ogg') + ) {
931-933: Clarify filename fallback condition.The condition
!filename && typeof filename !== 'string'is slightly confusing. It evaluates to:
trueforundefined/null→ uses basenamefalsefor""(empty string) → keeps empty stringIf an empty string should also trigger the fallback, simplify to
!filename. If preserving empty strings is intentional, a comment would help clarify.src/controllers/initializer.ts (1)
305-306: Empty catch blocks swallow errors silently.Multiple locations have empty catches (lines 305, 330, 354, 394) that discard all errors. While this may be intentional to prevent unhandled rejections from crashing the process, consider at least logging errors at debug level for troubleshooting.
Also,
.catch()without a handler (lines 330, 354, 394) is unusual—explicitly use.catch(() => {})or.catch((e) => { /* intentionally ignored */ })for clarity.Also applies to: 329-330, 353-354, 393-394
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
src/api/helpers/closes-browser.tssrc/api/layers/controls.layer.tssrc/api/layers/group.layer.tssrc/api/layers/profile.layer.tssrc/api/layers/retriever.layer.tssrc/api/layers/sender.layer.tssrc/api/layers/ui.layer.tssrc/controllers/initializer.tssrc/lib/wapi/functions/forward-messages.js
🧰 Additional context used
📓 Path-based instructions (5)
src/api/layers/*.layer.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Keep functionality layers in src/api/layers using the *.layer.ts naming (e.g., sender.layer.ts, listener.layer.ts, group.layer.ts, profile.layer.ts, controls.layer.ts, retriever.layer.ts)
Files:
src/api/layers/controls.layer.tssrc/api/layers/profile.layer.tssrc/api/layers/retriever.layer.tssrc/api/layers/ui.layer.tssrc/api/layers/group.layer.tssrc/api/layers/sender.layer.ts
src/controllers/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Controllers (initializer.ts for session creation, browser.ts for Puppeteer management, auth.ts for authentication/QR) live under src/controllers
Files:
src/controllers/initializer.ts
src/api/helpers/**/*.{ts,js}
📄 CodeRabbit inference engine (CLAUDE.md)
Put utility helpers (e.g., encryption, QR code utilities) under src/api/helpers
Files:
src/api/helpers/closes-browser.ts
src/lib/wapi/functions/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI functions in src/lib/wapi/functions are JavaScript files injected into the browser; after changing them, run
npm run build:wapito rebuild
Files:
src/lib/wapi/functions/forward-messages.js
src/lib/wapi/**/*.js
📄 CodeRabbit inference engine (CLAUDE.md)
WAPI layer code is built with webpack and injected into the Puppeteer browser context
Files:
src/lib/wapi/functions/forward-messages.js
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/lib/wapi/**/*.js : WAPI layer code is built with webpack and injected into the Puppeteer browser context
📚 Learning: 2025-09-08T17:49:03.345Z
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/api/layers/*.layer.ts : Keep functionality layers in src/api/layers using the *.layer.ts naming (e.g., sender.layer.ts, listener.layer.ts, group.layer.ts, profile.layer.ts, controls.layer.ts, retriever.layer.ts)
Applied to files:
src/api/layers/controls.layer.tssrc/api/layers/profile.layer.tssrc/api/layers/retriever.layer.tssrc/api/layers/group.layer.tssrc/api/layers/sender.layer.ts
📚 Learning: 2025-09-08T17:49:03.345Z
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/controllers/*.ts : Controllers (initializer.ts for session creation, browser.ts for Puppeteer management, auth.ts for authentication/QR) live under src/controllers
Applied to files:
src/controllers/initializer.tssrc/api/layers/retriever.layer.ts
📚 Learning: 2025-09-08T17:49:03.345Z
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/config/**/*.ts : Keep browser/Puppeteer and session management configuration under src/config
Applied to files:
src/api/layers/retriever.layer.ts
📚 Learning: 2025-09-08T17:49:03.345Z
Learnt from: CR
Repo: venomlib/venom PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-08T17:49:03.345Z
Learning: Applies to src/lib/wapi/**/*.js : WAPI layer code is built with webpack and injected into the Puppeteer browser context
Applied to files:
src/api/layers/retriever.layer.tssrc/api/layers/sender.layer.ts
🧬 Code graph analysis (6)
src/api/layers/profile.layer.ts (3)
src/lib/wapi/functions/send-message.js (3)
result(83-83)result(103-103)result(116-118)src/lib/wapi/functions/get-message-by-id.js (1)
result(36-36)src/lib/wapi/functions/get-list-mute.js (1)
interfaceMute(34-37)
src/api/layers/retriever.layer.ts (5)
src/api/helpers/layers-interface.ts (1)
checkValuesSender(10-34)src/lib/wapi/serializers/serialize-message.js (1)
chats(6-6)src/lib/wapi/wapi.js (3)
chat(443-443)chat(502-502)chat(511-511)src/api/model/index.ts (1)
WhatsappProfile(14-14)src/api/model/whatsapp-profile.ts (1)
WhatsappProfile(3-10)
src/api/helpers/closes-browser.ts (3)
app.js (1)
browser(25-25)src/controllers/browser.ts (1)
browser(540-543)src/api/layers/host.layer.ts (1)
tryAutoClose(66-76)
src/api/layers/ui.layer.ts (1)
src/api/helpers/layers-interface.ts (1)
checkValuesSender(10-34)
src/api/layers/group.layer.ts (4)
src/api/helpers/layers-interface.ts (1)
checkValuesSender(10-34)src/lib/wapi/functions/send-file.js (1)
result(107-223)src/lib/wapi/functions/send-ptt.js (1)
result(69-170)src/lib/wapi/functions/demote-participant.js (1)
demoteParticipant(1-30)
src/api/layers/sender.layer.ts (4)
src/api/helpers/layers-interface.ts (1)
checkValuesSender(10-34)src/api/model/result.ts (1)
SendFileResult(19-24)src/api/helpers/download-file.ts (1)
downloadFileToBase64(3-43)src/api/helpers/dowload-meta.ts (1)
dowloadMetaFileBase64(5-79)
🪛 Biome (2.1.2)
src/lib/wapi/functions/forward-messages.js
[error] 66-66: Shouldn't redeclare 'obj'. Consider to delete it or rename it.
'obj' is defined here:
(lint/suspicious/noRedeclare)
🔇 Additional comments (14)
src/api/layers/group.layer.ts (5)
10-11: LGTM!Import paths simplified to consolidated modules, which improves maintainability.
125-161: LGTM!Clean refactor to async/await with proper validation and error propagation for string parameters.
168-207: LGTM!Consistent async/await refactor with correct type validation.
246-272: Thetimeparameter is not validated.The
timeparameter is passed toWAPI.getGroupParticipantbut is not included in the validation check array, unlikegroupId. Iftimeis a required string parameter, it should be validated for consistency with the other methods.🔎 Proposed fix if validation is needed
const check = [ { param: 'groupId', type: type, value: groupId, function: typeFunction, isUser: true + }, + { + param: 'time', + type: type, + value: time, + function: typeFunction, + isUser: false } ];
405-429: LGTM!Consistent async/await refactor with proper validation.
src/api/layers/ui.layer.ts (1)
44-69: LGTM! Clean async/await refactor.The refactoring from Promise constructor to direct async/await with throw-based error handling is well-executed and consistent with the broader PR changes across other layers.
src/api/helpers/closes-browser.ts (1)
4-31: LGTM! Simplified monitoring loop.The refactor from Promise-based nested loops to a straightforward infinite loop with async/await improves readability while preserving the monitoring behavior. The exit conditions are properly handled with early returns.
src/api/layers/profile.layer.ts (1)
38-53: LGTM! Consistent async refactor.The migration from Promise constructor to direct async/await with throw-based error handling aligns with the patterns applied across other layers in this PR.
src/api/layers/controls.layer.ts (1)
45-71: LGTM! Consistent async/await refactoring.The refactoring of
markUnseenMessage,markMarkSeenMessage, andpinChatfrom Promise constructors to direct async/await with throw-based error handling is clean and aligns with the PR objectives.Also applies to: 78-104, 138-149
src/api/layers/retriever.layer.ts (3)
1-3: LGTM! Import organization.The import reordering improves code organization without functional impact.
30-42: LGTM! Thorough async/await refactoring.The refactoring of
getAllMessagesDate,getNewMessageId,checkNumberStatus, andgetNumberProfileconsistently applies the direct async/await pattern with throw-based error handling, aligning with the PR objectives.Also applies to: 44-70, 144-153, 272-296
111-115: LGTM! Simplified return path.The simplification to directly return the WAPI result improves readability without changing behavior.
src/api/layers/sender.layer.ts (1)
53-70: Consistent async/await conversion looks good.The refactor to async/await with throw-based error handling is applied consistently across all methods. The pattern of validating parameters, executing the WAPI call, and throwing on error is clear and maintainable.
src/controllers/initializer.ts (1)
131-139: Clean async/await refactor.The conversion from Promise constructor pattern to a direct async function improves readability significantly. The error handling via
throwand the linear flow make the initialization sequence much easier to follow. Status callbacks are properly integrated throughout.
Fixes # .
Changes proposed in this pull request
To test (it takes a while):
npm install github:<username>/venom#<branch>Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.