Fix various issues relating to voice channels.

This commit is contained in:
Paul
2021-06-24 12:33:16 +01:00
parent 9a417aa6ad
commit b45ea266d8
6 changed files with 81 additions and 78 deletions

View File

@@ -1,3 +1,3 @@
#!/bin/bash
export version=0.5.1-alpha.0
export version=0.5.1-alpha.0-patch.0
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs

View File

@@ -232,7 +232,9 @@ impl Channel {
}
// Remove from server object.
if let Channel::TextChannel { server, .. } = &self {
match &self {
Channel::TextChannel { server, .. }
| Channel::VoiceChannel { server, .. } => {
let server = Ref::from_unchecked(server.clone()).fetch_server().await?;
let mut update = doc! {
"$pull": {
@@ -285,6 +287,8 @@ impl Channel {
operation: "update_one",
with: "servers",
})?;
},
_ => {}
}
// Finally, delete the channel object.

View File

@@ -45,7 +45,9 @@ pub async fn req(user: User, target: Ref, data: Json<Data>) -> Result<()> {
}
match &target {
Channel::Group { id, icon, .. } | Channel::TextChannel { id, icon, .. } => {
Channel::Group { id, icon, .. }
| Channel::TextChannel { id, icon, .. }
| Channel::VoiceChannel { id, icon, .. } => {
let mut set = doc! {};
let mut unset = doc! {};

View File

@@ -35,14 +35,9 @@ pub async fn req(target: Ref) -> Result<JsonValue> {
let channel = Ref::from_unchecked(channel).fetch_channel().await?;
let creator = Ref::from_unchecked(creator).fetch_user().await?;
if let Channel::TextChannel {
id,
server,
name,
description,
..
} = channel
{
match channel {
Channel::TextChannel { id, server, name, description, .. }
| Channel::VoiceChannel { id, server, name, description, .. } => {
let server = Ref::from_unchecked(server).fetch_server().await?;
Ok(json!(InviteResponse::Server {
@@ -56,8 +51,8 @@ pub async fn req(target: Ref) -> Result<JsonValue> {
user_name: creator.username,
user_avatar: creator.avatar
}))
} else {
unreachable!()
}
_ => unreachable!()
}
}
_ => unreachable!(),

View File

@@ -10,10 +10,12 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
match target {
Invite::Server { channel, .. } => {
let channel = Ref::from_unchecked(channel).fetch_channel().await?;
let server = if let Channel::TextChannel { server, .. } = &channel {
let server = match &channel {
Channel::TextChannel { server, .. }
| Channel::VoiceChannel { server, .. } => {
Ref::from_unchecked(server.clone()).fetch_server().await?
} else {
unreachable!()
}
_ => unreachable!()
};
server.join_member(&user.id).await?;

View File

@@ -1 +1 @@
pub const VERSION: &str = "0.5.1-alpha.0";
pub const VERSION: &str = "0.5.1-alpha.0-patch.0";