feat: Add upload under account scope (#7914)

This commit is contained in:
Shivam Mishra
2023-09-19 09:51:54 +05:30
committed by GitHub
parent 2429daa45c
commit 53d530b815
8 changed files with 28 additions and 19 deletions

View File

@@ -138,8 +138,9 @@ class Rack::Attack
end
## Prevent Abuse of attachment upload APIs ##
throttle('/api/v1/upload', limit: 60, period: 1.hour) do |req|
req.ip if req.path_without_extentions == '/api/v1/upload' && req.post?
throttle('/api/v1/accounts/:account_id/upload', limit: 60, period: 1.hour) do |req|
match_data = %r{/api/v1/accounts/(?<account_id>\d+)/upload}.match(req.path)
match_data[:account_id] if match_data.present?
end
## ----------------------------------------------- ##