forked from jmug/stoatchat
Enhancement: Routes with no body should return 204 No Content.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::database::*;
|
||||
use crate::notifications::events::ClientboundNotification;
|
||||
use crate::util::result::{Error, Result};
|
||||
use crate::util::result::{Error, Result, EmptyResponse};
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use rauth::auth::{Auth, Session};
|
||||
@@ -31,11 +31,11 @@ pub async fn req(
|
||||
user: User,
|
||||
data: Json<Data>,
|
||||
_ignore_id: String,
|
||||
) -> Result<()> {
|
||||
) -> Result<EmptyResponse> {
|
||||
if user.bot.is_some() {
|
||||
return Err(Error::IsBot)
|
||||
}
|
||||
|
||||
|
||||
data.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
@@ -69,5 +69,5 @@ pub async fn req(
|
||||
}
|
||||
.publish_as_user(user.id.clone());
|
||||
|
||||
Ok(())
|
||||
Ok(EmptyResponse {})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::notifications::events::ClientboundNotification;
|
||||
use crate::util::result::{Error, Result};
|
||||
use crate::util::result::{Error, Result, EmptyResponse};
|
||||
use crate::{database::*, notifications::events::RemoveUserField};
|
||||
|
||||
use mongodb::bson::{doc, to_document};
|
||||
@@ -29,7 +29,7 @@ pub struct Data {
|
||||
}
|
||||
|
||||
#[patch("/<_ignore_id>", data = "<data>")]
|
||||
pub async fn req(user: User, data: Json<Data>, _ignore_id: String) -> Result<()> {
|
||||
pub async fn req(user: User, data: Json<Data>, _ignore_id: String) -> Result<EmptyResponse> {
|
||||
let mut data = data.into_inner();
|
||||
|
||||
data.validate()
|
||||
@@ -40,7 +40,7 @@ pub async fn req(user: User, data: Json<Data>, _ignore_id: String) -> Result<()>
|
||||
&& data.avatar.is_none()
|
||||
&& data.remove.is_none()
|
||||
{
|
||||
return Ok(());
|
||||
return Ok(EmptyResponse {});
|
||||
}
|
||||
|
||||
let mut unset = doc! {};
|
||||
@@ -152,5 +152,5 @@ pub async fn req(user: User, data: Json<Data>, _ignore_id: String) -> Result<()>
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(EmptyResponse {})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user