Conversation
WalkthroughThe pull request extends user storage middleware to capture chat member joins, improves error detection in message forwarding with specific handling for invalid message IDs, removes redundant separator messages from the ban-all workflow, and adds message deletion before initiating ban operations. Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/modules/tg-logger/report.ts (1)
142-154:⚠️ Potential issue | 🟠 Major
banAll(...)is no longer awaited — return value discarded and rejections become unhandled.
banAllreturnsPromise<string | null>and can perform multiple API calls (includingthis.log) that may reject. With the missingawait, any rejection bubbles up as an unhandled promise rejection (which your ownexceptionhandler treats asUNHANDLED_PROMISE), and the returned string (e.g. the "ERROR" message when logging the banAll header fails) is silently dropped instead of being surfaced as callback feedback.If the fire-and-forget is intentional (so
editReportMessageruns immediately), at minimum attach a.catchto avoid unhandled rejections. Otherwise, await it and, ideally, surface the error string via the menufeedback.Proposed fix
- await ctx.api.deleteMessage(data.message.chat.id, data.message.message_id).catch(() => {}) - modules - .get("tgLogger") - .banAll( - data.message.from, - ctx.from, - "BAN", - `Started after report by ${data.reporter.username ?? data.reporter.id}` - ) - await editReportMessage(data, ctx, "🚨 Start BAN ALL") - return null + await ctx.api.deleteMessage(data.message.chat.id, data.message.message_id).catch(() => {}) + void modules + .get("tgLogger") + .banAll( + data.message.from, + ctx.from, + "BAN", + `Started after report by ${data.reporter.username ?? data.reporter.id}` + ) + .catch(() => {}) + await editReportMessage(data, ctx, "🚨 Start BAN ALL") + return null🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/modules/tg-logger/report.ts` around lines 142 - 154, The call to modules.get("tgLogger").banAll in the cb handler is not awaited so its Promise rejection and return value are lost; either await the result and surface its returned string into the callback feedback or, if you truly want fire-and-forget, attach a .catch to handle errors. Update the cb implementation around modules.get("tgLogger").banAll to use either "await modules.get('tgLogger').banAll(...)" and propagate/return the resulting string into editReportMessage/menu feedback, or chain ".catch(err => { /* log via this.log/exception handler or call editReportMessage with error */ })" to prevent unhandled rejections; reference the cb function, modules.get("tgLogger").banAll, and editReportMessage when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/middlewares/message-user-storage.ts`:
- Around line 47-55: The current chat_member handler only caches users for old
status "left" → "member", so other join transitions (e.g., "kicked"→"member"
after unban or "restricted"→"member") are missed; update the filter used in
this.composer.on("chat_member") to detect a broader set of join
transitions—either by checking that ctx.chatMember.new_chat_member.status ===
"member" and ctx.chatMember.old_chat_member.status is not "member" (or belongs
to a set like {"left","kicked","restricted"})—then continue to call
this.userStorage.set(...) with ctx.chatMember.new_chat_member.user.id and the
user object as before; ensure you reference the same symbols (this.composer.on,
filter callback, ctx.chatMember.old_chat_member.status,
ctx.chatMember.new_chat_member.status, this.userStorage.set) so the change is
localized and safe.
---
Outside diff comments:
In `@src/modules/tg-logger/report.ts`:
- Around line 142-154: The call to modules.get("tgLogger").banAll in the cb
handler is not awaited so its Promise rejection and return value are lost;
either await the result and surface its returned string into the callback
feedback or, if you truly want fire-and-forget, attach a .catch to handle
errors. Update the cb implementation around modules.get("tgLogger").banAll to
use either "await modules.get('tgLogger').banAll(...)" and propagate/return the
resulting string into editReportMessage/menu feedback, or chain ".catch(err => {
/* log via this.log/exception handler or call editReportMessage with error */
})" to prevent unhandled rejections; reference the cb function,
modules.get("tgLogger").banAll, and editReportMessage when making the change.
🪄 Autofix (Beta)
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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 95b3cee2-1587-4d01-9686-e8dbfe74073e
📒 Files selected for processing (3)
src/middlewares/message-user-storage.tssrc/modules/tg-logger/index.tssrc/modules/tg-logger/report.ts
No description provided.