hotfix: check if the group is in the backend db#80
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAdded backend verification to a bot middleware that previously relied on a TEMP_redis flag, and bumped Changes
Sequence DiagramsequenceDiagram
participant Client
participant Middleware
participant TEMP_redis
participant Backend_API
participant Membership_Handler
Client->>Middleware: Request (ctx.chat.id)
Middleware->>TEMP_redis: has(chat_key)?
alt TEMP_redis true
Middleware->>Backend_API: api.tg.groups.getById({ telegramId })
Backend_API-->>Middleware: Group or null
alt Group exists
Middleware->>Client: next() (skip membership handling)
else Group missing
Middleware->>Membership_Handler: perform admin/member checks
Membership_Handler->>Membership_Handler: create group / TEMP_redis.write if needed
end
else TEMP_redis false
Middleware->>Membership_Handler: perform admin/member checks
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 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
🤖 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/bot-membership-handler.ts`:
- Around line 54-57: The middleware currently calls
api.tg.groups.getById.query(...) directly which can throw and break the filter;
update the call in bot-membership-handler to handle transient backend errors
(e.g., append .catch(() => null) or wrap in try/catch) so that backendGroup
becomes null on failure and the middleware falls through to the create flow;
target the line using TEMP_redis, api.tg.groups.getById.query and the
backendGroup variable and ensure you still return next() only when backendGroup
is non-null.
🪄 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: 42b65886-f69b-448f-afac-ba83af2c1098
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
package.jsonsrc/middlewares/bot-membership-handler.ts
No description provided.