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,12 +1,12 @@
use crate::database::*;
use crate::util::result::{Error, Result};
use crate::util::result::{Error, Result, EmptyResponse};
#[put("/<target>/ack")]
pub async fn req(user: User, target: Ref) -> Result<()> {
pub async fn req(user: User, target: Ref) -> Result<EmptyResponse> {
if user.bot.is_some() {
return Err(Error::IsBot)
}
let target = target.fetch_server().await?;
let perm = permissions::PermissionCalculator::new(&user)
@@ -18,5 +18,6 @@ pub async fn req(user: User, target: Ref) -> Result<()> {
Err(Error::MissingPermission)?
}
target.mark_as_read(&user.id).await
target.mark_as_read(&user.id).await;
Ok(EmptyResponse {})
}