mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-14 08:23:59 +00:00
Guard CreateCommunity, represent impossible error with Infallible
This commit is contained in:
parent
0e0ea559f0
commit
98f90d6800
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>)),
|
||||
)
|
||||
// Community
|
||||
.service(
|
||||
web::resource("/community")
|
||||
.guard(guard::Post())
|
||||
.wrap(rate_limit.post())
|
||||
.route(web::post().to(route_post::<CreateCommunity>)),
|
||||
)
|
||||
.service(
|
||||
web::scope("/community")
|
||||
.wrap(rate_limit.message())
|
||||
.route("", web::post().to(route_post::<CreateCommunity>))
|
||||
.route("", web::get().to(route_get::<GetCommunity>))
|
||||
.route("", web::put().to(route_post::<EditCommunity>))
|
||||
.route("/list", web::get().to(route_get::<ListCommunities>))
|
||||
|
|
|
@ -120,7 +120,7 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WSSession {
|
|||
.then(|res, _, ctx| {
|
||||
match res {
|
||||
Ok(Ok(res)) => ctx.text(res),
|
||||
Ok(Err(e)) => error!("{}", e),
|
||||
Ok(Err(e)) => match e {},
|
||||
Err(e) => error!("{}", &e),
|
||||
}
|
||||
actix::fut::ready(())
|
||||
|
|
|
@ -38,7 +38,7 @@ pub struct Disconnect {
|
|||
|
||||
/// The messages sent to websocket clients
|
||||
#[derive(Serialize, Deserialize, Message)]
|
||||
#[rtype(result = "Result<String, failure::Error>")]
|
||||
#[rtype(result = "Result<String, std::convert::Infallible>")]
|
||||
pub struct StandardMessage {
|
||||
/// Id of the client session
|
||||
pub id: ConnectionId,
|
||||
|
@ -905,6 +905,7 @@ where
|
|||
match op2 {
|
||||
UserOperation::Register => rate_limiter.register().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,
|
||||
}
|
||||
}
|
||||
|
@ -963,7 +964,7 @@ impl Handler<Disconnect> for ChatServer {
|
|||
|
||||
/// Handler for Message message.
|
||||
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 {
|
||||
let fut = self.parse_json_message(msg, ctx);
|
||||
|
|
Loading…
Reference in a new issue