fix: enforce email limits for agent invitations

Atomically reserve Chatwoot Cloud account email capacity before sending new agent invitations, including bulk creation, and roll back with HTTP 429 when the limit is exhausted.
This commit is contained in:
Sony Mathew
2026-07-20 18:48:33 +05:30
parent bf0a10c780
commit 0c6ee49216
8 changed files with 162 additions and 4 deletions
+14
View File
@@ -42,4 +42,18 @@ module CustomExceptions::Account
I18n.t 'errors.plan_upgrade_required.failed'
end
end
class EmailLimitExceeded < CustomExceptions::Base
def message
I18n.t('errors.account.email_limit_exceeded')
end
def to_hash
{ error: message }
end
def http_status
:too_many_requests
end
end
end