mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-24 03:41:32 +00:00
Send error message when rate limit is reached (#2527)
* Send error message when rate limit is reached * l18n key
This commit is contained in:
parent
5e871ca7ba
commit
9393195827
1 changed files with 4 additions and 8 deletions
|
@ -1,8 +1,5 @@
|
||||||
use crate::{utils::get_ip, IpAddr};
|
use crate::{error::LemmyError, utils::get_ip, IpAddr};
|
||||||
use actix_web::{
|
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
|
||||||
dev::{Service, ServiceRequest, ServiceResponse, Transform},
|
|
||||||
HttpResponse,
|
|
||||||
};
|
|
||||||
use futures::future::{ok, Ready};
|
use futures::future::{ok, Ready};
|
||||||
use rate_limiter::{RateLimitType, RateLimiter};
|
use rate_limiter::{RateLimitType, RateLimiter};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -177,10 +174,9 @@ where
|
||||||
service.call(req).await
|
service.call(req).await
|
||||||
} else {
|
} else {
|
||||||
let (http_req, _) = req.into_parts();
|
let (http_req, _) = req.into_parts();
|
||||||
// if rate limit was hit, respond with http 400
|
Ok(ServiceResponse::from_err(
|
||||||
Ok(ServiceResponse::new(
|
LemmyError::from_message("rate_limit_error"),
|
||||||
http_req,
|
http_req,
|
||||||
HttpResponse::BadRequest().finish(),
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue