Fix various issues relating to voice channels.
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/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
|
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs
|
||||||
|
|||||||
@@ -232,59 +232,63 @@ impl Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove from server object.
|
// Remove from server object.
|
||||||
if let Channel::TextChannel { server, .. } = &self {
|
match &self {
|
||||||
let server = Ref::from_unchecked(server.clone()).fetch_server().await?;
|
Channel::TextChannel { server, .. }
|
||||||
let mut update = doc! {
|
| Channel::VoiceChannel { server, .. } => {
|
||||||
"$pull": {
|
let server = Ref::from_unchecked(server.clone()).fetch_server().await?;
|
||||||
"channels": id
|
let mut update = doc! {
|
||||||
}
|
"$pull": {
|
||||||
};
|
"channels": id
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(sys) = &server.system_messages {
|
if let Some(sys) = &server.system_messages {
|
||||||
let mut unset = doc! {};
|
let mut unset = doc! {};
|
||||||
|
|
||||||
if let Some(cid) = &sys.user_joined {
|
if let Some(cid) = &sys.user_joined {
|
||||||
if id == cid {
|
if id == cid {
|
||||||
unset.insert("system_messages.user_joined", 1);
|
unset.insert("system_messages.user_joined", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(cid) = &sys.user_left {
|
||||||
|
if id == cid {
|
||||||
|
unset.insert("system_messages.user_left", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(cid) = &sys.user_kicked {
|
||||||
|
if id == cid {
|
||||||
|
unset.insert("system_messages.user_kicked", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(cid) = &sys.user_banned {
|
||||||
|
if id == cid {
|
||||||
|
unset.insert("system_messages.user_banned", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if unset.len() > 0 {
|
||||||
|
update.insert("$unset", unset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(cid) = &sys.user_left {
|
get_collection("servers")
|
||||||
if id == cid {
|
.update_one(
|
||||||
unset.insert("system_messages.user_left", 1);
|
doc! {
|
||||||
}
|
"_id": server.id
|
||||||
}
|
},
|
||||||
|
update,
|
||||||
if let Some(cid) = &sys.user_kicked {
|
None,
|
||||||
if id == cid {
|
)
|
||||||
unset.insert("system_messages.user_kicked", 1);
|
.await
|
||||||
}
|
.map_err(|_| Error::DatabaseError {
|
||||||
}
|
operation: "update_one",
|
||||||
|
with: "servers",
|
||||||
if let Some(cid) = &sys.user_banned {
|
})?;
|
||||||
if id == cid {
|
},
|
||||||
unset.insert("system_messages.user_banned", 1);
|
_ => {}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if unset.len() > 0 {
|
|
||||||
update.insert("$unset", unset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get_collection("servers")
|
|
||||||
.update_one(
|
|
||||||
doc! {
|
|
||||||
"_id": server.id
|
|
||||||
},
|
|
||||||
update,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|_| Error::DatabaseError {
|
|
||||||
operation: "update_one",
|
|
||||||
with: "servers",
|
|
||||||
})?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, delete the channel object.
|
// Finally, delete the channel object.
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ pub async fn req(user: User, target: Ref, data: Json<Data>) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
match &target {
|
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 set = doc! {};
|
||||||
let mut unset = doc! {};
|
let mut unset = doc! {};
|
||||||
|
|
||||||
|
|||||||
@@ -35,29 +35,24 @@ pub async fn req(target: Ref) -> Result<JsonValue> {
|
|||||||
let channel = Ref::from_unchecked(channel).fetch_channel().await?;
|
let channel = Ref::from_unchecked(channel).fetch_channel().await?;
|
||||||
let creator = Ref::from_unchecked(creator).fetch_user().await?;
|
let creator = Ref::from_unchecked(creator).fetch_user().await?;
|
||||||
|
|
||||||
if let Channel::TextChannel {
|
match channel {
|
||||||
id,
|
Channel::TextChannel { id, server, name, description, .. }
|
||||||
server,
|
| Channel::VoiceChannel { id, server, name, description, .. } => {
|
||||||
name,
|
let server = Ref::from_unchecked(server).fetch_server().await?;
|
||||||
description,
|
|
||||||
..
|
Ok(json!(InviteResponse::Server {
|
||||||
} = channel
|
server_id: server.id,
|
||||||
{
|
server_name: server.name,
|
||||||
let server = Ref::from_unchecked(server).fetch_server().await?;
|
server_icon: server.icon,
|
||||||
|
server_banner: server.banner,
|
||||||
Ok(json!(InviteResponse::Server {
|
channel_id: id,
|
||||||
server_id: server.id,
|
channel_name: name,
|
||||||
server_name: server.name,
|
channel_description: description,
|
||||||
server_icon: server.icon,
|
user_name: creator.username,
|
||||||
server_banner: server.banner,
|
user_avatar: creator.avatar
|
||||||
channel_id: id,
|
}))
|
||||||
channel_name: name,
|
}
|
||||||
channel_description: description,
|
_ => unreachable!()
|
||||||
user_name: creator.username,
|
|
||||||
user_avatar: creator.avatar
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
unreachable!()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
|||||||
match target {
|
match target {
|
||||||
Invite::Server { channel, .. } => {
|
Invite::Server { channel, .. } => {
|
||||||
let channel = Ref::from_unchecked(channel).fetch_channel().await?;
|
let channel = Ref::from_unchecked(channel).fetch_channel().await?;
|
||||||
let server = if let Channel::TextChannel { server, .. } = &channel {
|
let server = match &channel {
|
||||||
Ref::from_unchecked(server.clone()).fetch_server().await?
|
Channel::TextChannel { server, .. }
|
||||||
} else {
|
| Channel::VoiceChannel { server, .. } => {
|
||||||
unreachable!()
|
Ref::from_unchecked(server.clone()).fetch_server().await?
|
||||||
|
}
|
||||||
|
_ => unreachable!()
|
||||||
};
|
};
|
||||||
|
|
||||||
server.join_member(&user.id).await?;
|
server.join_member(&user.id).await?;
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
pub const VERSION: &str = "0.5.1-alpha.0";
|
pub const VERSION: &str = "0.5.1-alpha.0-patch.0";
|
||||||
|
|||||||
Reference in New Issue
Block a user