feat: Ability to delete account for administrators (#1874)

## Description

Add account delete option in the user account settings.

Fixes #1555 

## Type of change

- [ ] New feature (non-breaking change which adds functionality)


![image](https://user-images.githubusercontent.com/40784971/110349673-edcc5200-8058-11eb-8ded-a31d15aa0759.png)

![image](https://user-images.githubusercontent.com/40784971/110349778-0c324d80-8059-11eb-9291-abfbffedde5e.png)


## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules

---------

Co-authored-by: Sojan Jose <sojan@pepalo.com>
Co-authored-by: Sojan Jose <sojan.official@gmail.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Pranjal Kushwaha
2025-04-03 10:41:39 +05:30
committed by GitHub
parent 8bf2081aff
commit 0dc2af3c78
37 changed files with 1030 additions and 311 deletions

View File

@@ -162,5 +162,6 @@ class Account < ApplicationRecord
end
Account.prepend_mod_with('Account')
Account.prepend_mod_with('Account::PlanUsageAndLimits')
Account.include_mod_with('Concerns::Account')
Account.include_mod_with('Audit::Account')

View File

@@ -39,33 +39,39 @@ module Reauthorizable
def prompt_reauthorization!
::Redis::Alfred.set(reauthorization_required_key, true)
mailer = AdministratorNotifications::ChannelNotificationsMailer.with(account: account)
case self.class.name
when 'Integrations::Hook'
process_integration_hook_reauthorization_emails(mailer)
process_integration_hook_reauthorization_emails
when 'Channel::FacebookPage'
mailer.facebook_disconnect(inbox).deliver_later
send_channel_reauthorization_email(:facebook_disconnect)
when 'Channel::Whatsapp'
mailer.whatsapp_disconnect(inbox).deliver_later
send_channel_reauthorization_email(:whatsapp_disconnect)
when 'Channel::Email'
mailer.email_disconnect(inbox).deliver_later
send_channel_reauthorization_email(:email_disconnect)
when 'AutomationRule'
update!(active: false)
mailer.automation_rule_disabled(self).deliver_later
handle_automation_rule_reauthorization
end
invalidate_inbox_cache unless instance_of?(::AutomationRule)
end
def process_integration_hook_reauthorization_emails(mailer)
def process_integration_hook_reauthorization_emails
if slack?
mailer.slack_disconnect.deliver_later
AdministratorNotifications::IntegrationsNotificationMailer.with(account: account).slack_disconnect.deliver_later
elsif dialogflow?
mailer.dialogflow_disconnect.deliver_later
AdministratorNotifications::IntegrationsNotificationMailer.with(account: account).dialogflow_disconnect.deliver_later
end
end
def send_channel_reauthorization_email(disconnect_type)
AdministratorNotifications::ChannelNotificationsMailer.with(account: account).public_send(disconnect_type, inbox).deliver_later
end
def handle_automation_rule_reauthorization
update!(active: false)
AdministratorNotifications::AccountNotificationMailer.with(account: account).automation_rule_disabled(self).deliver_later
end
# call this after you successfully Reauthorized the object in UI
def reauthorized!
::Redis::Alfred.delete(authorization_error_count_key)