Context
When a Telegram user deletes their chat with the bot or blocks the bot, the dispatcher continues sending messages to that user. When these messages reach the consumer and it tries to send them via Telegram, it fails with specific errors. Currently, these errors are not properly handled, causing issues in the message processing flow.
Objective
Implement proper error handling in the Telegram consumer to detect when users have blocked the bot or deleted the chat, and automatically mark these users as inactive in the database.
Technical Requirements
-
Error Detection in Consumer:
- Catch and identify specific Telegram errors:
403: Forbidden: bot was blocked by the user
403: Forbidden: bot was kicked from the chat
400: Bad Request: chat not found
400: Bad Request: group is deactivated
-
User Deactivation Flow:
- When these errors are detected, make an HTTP call to subscription-server
- Update the user's
active status to false in the database
- Log the deactivation event for monitoring
-
Subscription Server Endpoint:
- Create endpoint to handle user deactivation requests
- Update user's active status in database
- Return confirmation to consumer
Context
When a Telegram user deletes their chat with the bot or blocks the bot, the dispatcher continues sending messages to that user. When these messages reach the consumer and it tries to send them via Telegram, it fails with specific errors. Currently, these errors are not properly handled, causing issues in the message processing flow.
Objective
Implement proper error handling in the Telegram consumer to detect when users have blocked the bot or deleted the chat, and automatically mark these users as inactive in the database.
Technical Requirements
Error Detection in Consumer:
403: Forbidden: bot was blocked by the user403: Forbidden: bot was kicked from the chat400: Bad Request: chat not found400: Bad Request: group is deactivatedUser Deactivation Flow:
activestatus tofalsein the databaseSubscription Server Endpoint: