Files
leadchat/app/mailers/administrator_notifications/account_notification_mailer.rb
Pranav e863a52262 chore: Update account deletion email copy (#12317)
Update the email copies for account deletion emails 

## Manual Deletion 

<img width="1378" height="678" alt="Screenshot 2025-08-29 at 2 41 40 PM"
src="https://github.com/user-attachments/assets/63d7ad97-ad51-4a8b-9ef3-d427fa467f8a"
/>

## Inactive Deletion

<img width="2946" height="1808" alt="image"
src="https://github.com/user-attachments/assets/bb50d08c-8701-4f93-af29-0b1d948a4009"
/>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Sojan Jose <sojan@pepalo.com>
2025-08-31 16:01:41 +02:00

71 lines
2.3 KiB
Ruby

class AdministratorNotifications::AccountNotificationMailer < AdministratorNotifications::BaseMailer
def account_deletion_user_initiated(account, reason)
subject = 'Your Chatwoot account deletion has been scheduled'
action_url = settings_url('general')
meta = {
'account_name' => account.name,
'deletion_date' => format_deletion_date(account.custom_attributes['marked_for_deletion_at']),
'reason' => reason
}
send_notification(subject, action_url: action_url, meta: meta)
end
def account_deletion_for_inactivity(account, reason)
subject = 'Your Chatwoot account is scheduled for deletion due to inactivity'
action_url = settings_url('general')
meta = {
'account_name' => account.name,
'deletion_date' => format_deletion_date(account.custom_attributes['marked_for_deletion_at']),
'reason' => reason
}
send_notification(subject, action_url: action_url, meta: meta)
end
def contact_import_complete(resource)
subject = 'Contact Import Completed'
action_url = if resource.failed_records.attached?
Rails.application.routes.url_helpers.rails_blob_url(resource.failed_records)
else
"#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{resource.account.id}/contacts"
end
meta = {
'failed_contacts' => resource.total_records - resource.processed_records,
'imported_contacts' => resource.processed_records
}
send_notification(subject, action_url: action_url, meta: meta)
end
def contact_import_failed
subject = 'Contact Import Failed'
send_notification(subject)
end
def contact_export_complete(file_url, email_to)
subject = "Your contact's export file is available to download."
send_notification(subject, to: email_to, action_url: file_url)
end
def automation_rule_disabled(rule)
subject = 'Automation rule disabled due to validation errors.'
action_url = settings_url('automation/list')
meta = { 'rule_name' => rule.name }
send_notification(subject, action_url: action_url, meta: meta)
end
private
def format_deletion_date(deletion_date_str)
return 'Unknown' if deletion_date_str.blank?
Time.zone.parse(deletion_date_str).strftime('%B %d, %Y')
rescue StandardError
'Unknown'
end
end