Servers: Add route for creating channels.

Notifications: Subscribe to guild channels.
This commit is contained in:
Paul
2021-06-02 11:51:58 +01:00
parent f32f447233
commit 1713ad057d
8 changed files with 179 additions and 45 deletions

View File

@@ -108,6 +108,12 @@ pub async fn req(user: User, target: Ref) -> Result<()> {
Ok(())
}
Channel::TextChannel { .. } => unimplemented!()
Channel::TextChannel { .. } => {
if perm.get_manage_channel() {
target.delete().await
} else {
Err(Error::MissingPermission)
}
}
}
}

View File

@@ -24,6 +24,7 @@ pub struct Data {
#[post("/create", data = "<info>")]
pub async fn req(user: User, info: Json<Data>) -> Result<JsonValue> {
let info = info.into_inner();
info.validate()
.map_err(|error| Error::FailedValidation { error })?;
@@ -62,12 +63,9 @@ pub async fn req(user: User, info: Json<Data>) -> Result<JsonValue> {
let id = Ulid::new().to_string();
let channel = Channel::Group {
id,
nonce: Some(info.nonce.clone()),
name: info.name.clone(),
description: info
.description
.clone()
.unwrap_or_else(|| "A group.".to_string()),
nonce: Some(info.nonce),
name: info.name,
description: info.description,
owner: user.id,
recipients: set.into_iter().collect::<Vec<String>>(),
icon: None,