mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 11:21:32 +00:00
Guard CreateCommunity, represent impossible error with Infallible
This commit is contained in:
parent
db4454b52b
commit
904ebf34a5
3 changed files with 10 additions and 4 deletions
|
@ -40,10 +40,15 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
||||||
.route(web::get().to(route_get::<Search>)),
|
.route(web::get().to(route_get::<Search>)),
|
||||||
)
|
)
|
||||||
// Community
|
// Community
|
||||||
|
.service(
|
||||||
|
web::resource("/community")
|
||||||
|
.guard(guard::Post())
|
||||||
|
.wrap(rate_limit.post())
|
||||||
|
.route(web::post().to(route_post::<CreateCommunity>)),
|
||||||
|
)
|
||||||
.service(
|
.service(
|
||||||
web::scope("/community")
|
web::scope("/community")
|
||||||
.wrap(rate_limit.message())
|
.wrap(rate_limit.message())
|
||||||
.route("", web::post().to(route_post::<CreateCommunity>))
|
|
||||||
.route("", web::get().to(route_get::<GetCommunity>))
|
.route("", web::get().to(route_get::<GetCommunity>))
|
||||||
.route("", web::put().to(route_post::<EditCommunity>))
|
.route("", web::put().to(route_post::<EditCommunity>))
|
||||||
.route("/list", web::get().to(route_get::<ListCommunities>))
|
.route("/list", web::get().to(route_get::<ListCommunities>))
|
||||||
|
|
|
@ -120,7 +120,7 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WSSession {
|
||||||
.then(|res, _, ctx| {
|
.then(|res, _, ctx| {
|
||||||
match res {
|
match res {
|
||||||
Ok(Ok(res)) => ctx.text(res),
|
Ok(Ok(res)) => ctx.text(res),
|
||||||
Ok(Err(e)) => error!("{}", e),
|
Ok(Err(e)) => match e {},
|
||||||
Err(e) => error!("{}", &e),
|
Err(e) => error!("{}", &e),
|
||||||
}
|
}
|
||||||
actix::fut::ready(())
|
actix::fut::ready(())
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub struct Disconnect {
|
||||||
|
|
||||||
/// The messages sent to websocket clients
|
/// The messages sent to websocket clients
|
||||||
#[derive(Serialize, Deserialize, Message)]
|
#[derive(Serialize, Deserialize, Message)]
|
||||||
#[rtype(result = "Result<String, failure::Error>")]
|
#[rtype(result = "Result<String, std::convert::Infallible>")]
|
||||||
pub struct StandardMessage {
|
pub struct StandardMessage {
|
||||||
/// Id of the client session
|
/// Id of the client session
|
||||||
pub id: ConnectionId,
|
pub id: ConnectionId,
|
||||||
|
@ -905,6 +905,7 @@ where
|
||||||
match op2 {
|
match op2 {
|
||||||
UserOperation::Register => rate_limiter.register().wrap(ip, fut).await,
|
UserOperation::Register => rate_limiter.register().wrap(ip, fut).await,
|
||||||
UserOperation::CreatePost => rate_limiter.post().wrap(ip, fut).await,
|
UserOperation::CreatePost => rate_limiter.post().wrap(ip, fut).await,
|
||||||
|
UserOperation::CreateCommunity => rate_limiter.post().wrap(ip, fut).await,
|
||||||
_ => rate_limiter.message().wrap(ip, fut).await,
|
_ => rate_limiter.message().wrap(ip, fut).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -963,7 +964,7 @@ impl Handler<Disconnect> for ChatServer {
|
||||||
|
|
||||||
/// Handler for Message message.
|
/// Handler for Message message.
|
||||||
impl Handler<StandardMessage> for ChatServer {
|
impl Handler<StandardMessage> for ChatServer {
|
||||||
type Result = ResponseFuture<Result<String, failure::Error>>;
|
type Result = ResponseFuture<Result<String, std::convert::Infallible>>;
|
||||||
|
|
||||||
fn handle(&mut self, msg: StandardMessage, ctx: &mut Context<Self>) -> Self::Result {
|
fn handle(&mut self, msg: StandardMessage, ctx: &mut Context<Self>) -> Self::Result {
|
||||||
let fut = self.parse_json_message(msg, ctx);
|
let fut = self.parse_json_message(msg, ctx);
|
||||||
|
|
Loading…
Reference in a new issue