fix: move call system message to daemon,
check max participants when creating a token to avoid giving tokens but erroring when attempting to join, check if the channel actually supports voice
This commit is contained in:
@@ -107,7 +107,7 @@ auto_derived!(
|
||||
|
||||
/// Voice Information for when this channel is also a voice channel
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
voice: Option<VoiceInformation>
|
||||
voice: Option<VoiceInformation>,
|
||||
},
|
||||
#[deprecated = "Use TextChannel { voice } instead"]
|
||||
VoiceChannel {
|
||||
@@ -146,7 +146,7 @@ auto_derived!(
|
||||
pub struct VoiceInformation {
|
||||
/// Maximium amount of users allowed in the voice channel at once
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub max_users: Option<u32>
|
||||
pub max_users: Option<usize>,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -233,7 +233,7 @@ impl Channel {
|
||||
default_permissions: None,
|
||||
role_permissions: HashMap::new(),
|
||||
nsfw: data.nsfw.unwrap_or(false),
|
||||
voice: data.voice.map(|voice| voice.into())
|
||||
voice: data.voice.map(|voice| voice.into()),
|
||||
},
|
||||
v0::LegacyServerChannelType::Voice => Channel::TextChannel {
|
||||
id: id.clone(),
|
||||
@@ -245,7 +245,7 @@ impl Channel {
|
||||
default_permissions: None,
|
||||
role_permissions: HashMap::new(),
|
||||
nsfw: data.nsfw.unwrap_or(false),
|
||||
voice: Some(data.voice.unwrap_or_default().into())
|
||||
voice: Some(data.voice.unwrap_or_default().into()),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -454,17 +454,23 @@ impl Channel {
|
||||
/// Clone this channel's server id
|
||||
pub fn server(&self) -> Option<&str> {
|
||||
match self {
|
||||
Channel::TextChannel { server, .. } | Channel::VoiceChannel { server, .. } => Some(server),
|
||||
_ => None
|
||||
Channel::TextChannel { server, .. } | Channel::VoiceChannel { server, .. } => {
|
||||
Some(server)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets this channel's voice information
|
||||
pub fn voice(&self) -> Option<Cow<VoiceInformation>> {
|
||||
match self {
|
||||
Self::DirectMessage { .. } | Channel::VoiceChannel { .. } => Some(Cow::Owned(VoiceInformation::default())),
|
||||
Self::TextChannel { voice: Some(voice), .. } => Some(Cow::Borrowed(voice)),
|
||||
_ => None
|
||||
Self::DirectMessage { .. } | Channel::VoiceChannel { .. } => {
|
||||
Some(Cow::Owned(VoiceInformation::default()))
|
||||
}
|
||||
Self::TextChannel {
|
||||
voice: Some(voice), ..
|
||||
} => Some(Cow::Borrowed(voice)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,15 +545,13 @@ impl Channel {
|
||||
pub fn remove_field(&mut self, field: &FieldsChannel) {
|
||||
match field {
|
||||
FieldsChannel::Description => match self {
|
||||
Self::Group { description, .. }
|
||||
| Self::TextChannel { description, .. } => {
|
||||
Self::Group { description, .. } | Self::TextChannel { description, .. } => {
|
||||
description.take();
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
FieldsChannel::Icon => match self {
|
||||
Self::Group { icon, .. }
|
||||
| Self::TextChannel { icon, .. } => {
|
||||
Self::Group { icon, .. } | Self::TextChannel { icon, .. } => {
|
||||
icon.take();
|
||||
}
|
||||
_ => {}
|
||||
@@ -651,7 +655,7 @@ impl Channel {
|
||||
if let Some(v) = partial.voice {
|
||||
voice.replace(v);
|
||||
}
|
||||
},
|
||||
}
|
||||
Self::VoiceChannel { .. } => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ impl VoiceClient {
|
||||
.create_room(
|
||||
channel.id(),
|
||||
CreateRoomOptions {
|
||||
max_participants: voice.max_users.unwrap_or(0),
|
||||
max_participants: voice.max_users.unwrap_or(0) as u32,
|
||||
empty_timeout: 5 * 60, // 5 minutes,
|
||||
..Default::default()
|
||||
},
|
||||
|
||||
@@ -111,7 +111,7 @@ auto_derived!(
|
||||
|
||||
/// Voice Information for when this channel is also a voice channel
|
||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||
voice: Option<VoiceInformation>
|
||||
voice: Option<VoiceInformation>,
|
||||
},
|
||||
#[deprecated = "Use TextChannel { voice } instead"]
|
||||
VoiceChannel {
|
||||
@@ -159,7 +159,7 @@ auto_derived!(
|
||||
/// Maximium amount of users allowed in the voice channel at once
|
||||
#[cfg_attr(feature = "validator", validate(range(min = 1)))]
|
||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||
pub max_users: Option<u32>
|
||||
pub max_users: Option<usize>,
|
||||
}
|
||||
|
||||
/// Partial representation of a channel
|
||||
@@ -283,7 +283,7 @@ auto_derived!(
|
||||
|
||||
/// Voice Information for when this channel is also a voice channel
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub voice: Option<VoiceInformation>
|
||||
pub voice: Option<VoiceInformation>,
|
||||
}
|
||||
|
||||
/// New default permissions
|
||||
@@ -334,9 +334,8 @@ auto_derived!(
|
||||
/// Whether to force disconnect any other existing voice connections.
|
||||
///
|
||||
/// useful for disconnecting on another device and joining on a new.
|
||||
pub force_disconnect: Option<bool>
|
||||
pub force_disconnect: Option<bool>,
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
impl Channel {
|
||||
|
||||
Reference in New Issue
Block a user