lily_website

πŸ“‚ Telegram Notifications (Admin Actions)

⬅️ Back 🏠 Docs Root

The telegram/notifications feature handles interactive admin actions in Telegram, such as approving or rejecting bookings. It works in tandem with the redis/notifications feature, which provides the initial message.

πŸ—ΊοΈ Module Map

Component Description
πŸ“‚ Handlers Callback processing for admin actions
πŸ“‚ Logic Orchestrator and service layer
πŸ“‚ Contracts Data access interfaces
πŸ“‚ UI Message rendering and status views
πŸ“‚ Resources Texts, callbacks, keyboards
πŸ“‚ Tests Unit and integration tests

πŸ“‹ feature_setting.py

class NotificationsStates(StatesGroup):
    main = State()

STATES = NotificationsStates
GARBAGE_COLLECT = True

MENU_CONFIG = {
    "key": "notifications",
    "text": "✨ Notifications",
    "priority": 50,
    "is_admin": True,
}

πŸ”„ Logic Flow (Approval)

  1. Admin Clicks β€œApprove”: Telegram sends a callback to the bot.
  2. Orchestrator: Calls NotificationsService.confirm_appointment.
  3. Service: Sends request to Django API; enqueues send_appointment_notification in ARQ.
  4. UI: Updates Telegram message to show β€œApproved” with delivery status indicators.

πŸ”„ Logic Flow (Rejection)

  1. Admin Clicks β€œReject”: Bot shows a menu of reasons (Busy, Ill, No Materials, etc.).
  2. Admin Selects Reason: Bot calls cancel_appointment with the specific reason code.
  3. Service: Updates Django and enqueues a cancellation notification job.
  4. UI: Updates message to show β€œRejected” with the chosen reason.