Send error message when rate limit is reached (#2527)

* Send error message when rate limit is reached

* l18n key
pull/2535/head
Nutomic 2 years ago committed by GitHub
parent 5e871ca7ba
commit 9393195827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,5 @@
use crate::{utils::get_ip, IpAddr};
use actix_web::{
dev::{Service, ServiceRequest, ServiceResponse, Transform},
HttpResponse,
};
use crate::{error::LemmyError, utils::get_ip, IpAddr};
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
use futures::future::{ok, Ready};
use rate_limiter::{RateLimitType, RateLimiter};
use serde::{Deserialize, Serialize};
@ -177,10 +174,9 @@ where
service.call(req).await
} else {
let (http_req, _) = req.into_parts();
// if rate limit was hit, respond with http 400
Ok(ServiceResponse::new(
Ok(ServiceResponse::from_err(
LemmyError::from_message("rate_limit_error"),
http_req,
HttpResponse::BadRequest().finish(),
))
}
})

Loading…
Cancel
Save