Enhancement: Routes with no body should return 204 No Content.
This commit is contained in:
@@ -6,7 +6,7 @@ use crate::database::*;
|
||||
use crate::database::permissions::channel::ChannelPermission;
|
||||
use crate::database::permissions::server::ServerPermission;
|
||||
use crate::notifications::events::ClientboundNotification;
|
||||
use crate::util::result::{Error, Result};
|
||||
use crate::util::result::{Error, Result, EmptyResponse};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Values {
|
||||
@@ -20,7 +20,7 @@ pub struct Data {
|
||||
}
|
||||
|
||||
#[put("/<target>/permissions/<role_id>", data = "<data>", rank = 2)]
|
||||
pub async fn req(user: User, target: Ref, role_id: String, data: Json<Data>) -> Result<()> {
|
||||
pub async fn req(user: User, target: Ref, role_id: String, data: Json<Data>) -> Result<EmptyResponse> {
|
||||
let target = target.fetch_server().await?;
|
||||
|
||||
let perm = permissions::PermissionCalculator::new(&user)
|
||||
@@ -38,7 +38,7 @@ pub async fn req(user: User, target: Ref, role_id: String, data: Json<Data>) ->
|
||||
|
||||
let server_permissions: u32 = ServerPermission::View as u32 | data.permissions.server;
|
||||
let channel_permissions: u32 = ChannelPermission::View as u32 | data.permissions.channel;
|
||||
|
||||
|
||||
get_collection("servers")
|
||||
.update_one(
|
||||
doc! { "_id": &target.id },
|
||||
@@ -57,7 +57,7 @@ pub async fn req(user: User, target: Ref, role_id: String, data: Json<Data>) ->
|
||||
operation: "update_one",
|
||||
with: "server"
|
||||
})?;
|
||||
|
||||
|
||||
ClientboundNotification::ServerRoleUpdate {
|
||||
id: target.id.clone(),
|
||||
role_id,
|
||||
@@ -71,5 +71,5 @@ pub async fn req(user: User, target: Ref, role_id: String, data: Json<Data>) ->
|
||||
}
|
||||
.publish(target.id);
|
||||
|
||||
Ok(())
|
||||
Ok(EmptyResponse)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user