1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-07-02 16:38:36 +00:00

allow for different timeframes for configuration

This commit is contained in:
Matthias Ahouansou 2024-06-26 13:36:04 +01:00
parent bdf12c2bbd
commit 024f910bf9
No known key found for this signature in database
3 changed files with 32 additions and 7 deletions

View file

@ -20,7 +20,10 @@ use axum_extra::{
use bytes::{BufMut, BytesMut};
use http::{Request, StatusCode};
use ruma::{
api::{client::error::ErrorKind, AuthScheme, IncomingRequest, OutgoingResponse},
api::{
client::error::{ErrorKind, RetryAfter},
AuthScheme, IncomingRequest, OutgoingResponse,
},
server_util::authorization::XMatrix,
CanonicalJsonValue, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId, UserId,
};
@ -357,14 +360,16 @@ where
}
};
if let Err(retry_after_ms) = {
if let Err(retry_after) = {
services()
.rate_limiting
.update_or_reject(target, metadata)
.map_err(Some)
} {
return Err(Error::BadRequest(
ErrorKind::LimitExceeded { retry_after_ms },
ErrorKind::LimitExceeded {
retry_after: retry_after.map(|dur| RetryAfter::Delay(dur)),
},
"Rate limit exceeded.",
));
}