fix: make conversation transcript rate limit configurable (#13740)
## Summary - The conversation transcript endpoint rate limit is hardcoded at 30 requests/hour per account with no way to override it - Self-hosted users with active accounts hit this limit and get 429 errors across all channels - Add `RATE_LIMIT_CONVERSATION_TRANSCRIPT` env var (default: `1000`) to make it configurable, consistent with other throttles like `RATE_LIMIT_CONTACT_SEARCH` and `RATE_LIMIT_REPORTS_API_ACCOUNT_LEVEL`
This commit is contained in:
@@ -185,7 +185,8 @@ class Rack::Attack
|
||||
###-----------------------------------------------###
|
||||
|
||||
## Prevent Abuse of Converstion Transcript APIs ###
|
||||
throttle('/api/v1/accounts/:account_id/conversations/:conversation_id/transcript', limit: 30, period: 1.hour) do |req|
|
||||
throttle('/api/v1/accounts/:account_id/conversations/:conversation_id/transcript',
|
||||
limit: ENV.fetch('RATE_LIMIT_CONVERSATION_TRANSCRIPT', '1000').to_i, period: 1.hour) do |req|
|
||||
match_data = %r{/api/v1/accounts/(?<account_id>\d+)/conversations/(?<conversation_id>\d+)/transcript}.match(req.path)
|
||||
match_data[:account_id] if match_data.present?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user