Enhancement: Routes with no body should return 204 No Content.

This commit is contained in:
heikkari
2021-08-16 15:34:44 +03:00
parent 48d2fbe5ae
commit 721ca3a4f5
30 changed files with 124 additions and 116 deletions

View File

@@ -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 {})
}