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

@@ -40,34 +40,13 @@ pub async fn req(user: User, info: Json<Data>) -> Result<JsonValue> {
let id = Ulid::new().to_string();
let cid = Ulid::new().to_string();
Channel::TextChannel {
id: cid.clone(),
server: id.clone(),
nonce: Some(info.nonce.clone()),
name: "general".to_string(),
description: None,
icon: None,
}.publish().await?;
let server = Server {
id: id.clone(),
nonce: Some(info.nonce.clone()),
owner: user.id.clone(),
name: info.name.clone(),
channels: vec![ cid ],
icon: None,
banner: None,
};
get_collection("server_members")
.insert_one(
doc! {
"_id": {
"server": id,
"user": user.id
"server": &id,
"user": &user.id
}
},
None,
@@ -78,6 +57,29 @@ pub async fn req(user: User, info: Json<Data>) -> Result<JsonValue> {
with: "server_members",
})?;
Channel::TextChannel {
id: cid.clone(),
server: id.clone(),
nonce: Some(info.nonce.clone()),
name: "general".to_string(),
description: None,
icon: None,
}
.publish()
.await?;
let server = Server {
id: id.clone(),
nonce: Some(info.nonce.clone()),
owner: user.id.clone(),
name: info.name.clone(),
channels: vec![cid],
icon: None,
banner: None,
};
server.clone().publish().await?;
Ok(json!(server))