Closed GMayank0310 closed 3 weeks ago
The changes introduce a new feature that allows users to leave a bot, including email notifications for bot owners when a member departs. This involves modifications to several files, including the addition of email templates, a new endpoint in the user router, and updates to account processing logic. Tests have been added to ensure the functionality works as intended, covering various scenarios related to leaving a bot.
Files | Change Summary |
---|---|
email.yaml |
Added email template configurations for notifications when users leave a bot, including subject and body content. |
kairon/api/app/routers/user.py |
Introduced a new asynchronous endpoint leave_bot for users to leave a bot, with access control and email notification functionality. |
kairon/shared/account/data_objects.py |
Added a new field leave_bot_owner_notification to the MailTemplates class for storing notification details related to bot owners. |
kairon/shared/account/processor.py |
Added a static method process_leave_bot to manage the logic for users leaving a bot, including checks for ownership and active integration tokens, and updated email template loading. |
kairon/shared/utils.py |
Introduced a new static method __handle_member_left_bot for handling email notifications when a member leaves a bot and updated the mail formatting function to include this handler. |
template/emails/leaveBotOwnerNotification.html |
Created a new HTML email template for notifying bot owners when a member leaves their bot, with a responsive design and dynamic content placeholders. |
tests/integration_test/services_test.py |
Added new test functions to validate the functionality of leaving a bot, covering successful leave, owner restrictions, integration token checks, and non-existent bot scenarios. |
sequenceDiagram
participant User
participant UserRouter
participant AccountProcessor
participant MailUtility
participant MailTemplates
User->>UserRouter: leave_bot(bot_id)
UserRouter->>AccountProcessor: process_leave_bot(bot_id, current_user)
AccountProcessor->>AccountProcessor: Check ownership and tokens
AccountProcessor-->>UserRouter: Success/Failure response
UserRouter->>MailUtility: Send notification if applicable
MailUtility->>MailTemplates: Generate email content
MailUtility-->>User: Email sent confirmation
π°
In the meadow, hops a little hare,
With news of bots, weβre here to share.
When members leave, an email flies,
To keep the owners wise and spry!
So hop along, and spread the cheer,
For every change brings joy, my dear!
πΌ
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Summary by CodeRabbit
New Features
Bug Fixes
Tests