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,10 +1,10 @@
use crate::util::result::{Error, Result};
use crate::util::result::{Error, Result, EmptyResponse};
use crate::{database::*, notifications::events::ClientboundNotification};
use mongodb::bson::doc;
#[delete("/<target>")]
pub async fn req(user: User, target: Ref) -> Result<()> {
pub async fn req(user: User, target: Ref) -> Result<EmptyResponse> {
let target = target.fetch_channel().await?;
let perm = permissions::PermissionCalculator::new(&user)
@@ -37,7 +37,7 @@ pub async fn req(user: User, target: Ref) -> Result<()> {
with: "channel",
})?;
Ok(())
Ok(EmptyResponse {})
}
Channel::Group {
id,
@@ -103,7 +103,7 @@ pub async fn req(user: User, target: Ref) -> Result<()> {
.await
.ok();
Ok(())
Ok(EmptyResponse {})
}
Channel::TextChannel { .. } |
Channel::VoiceChannel { .. } => {