refactor: seperate out disconnect logic
This commit is contained in:
@@ -214,25 +214,43 @@ pub async fn ingress(
|
|||||||
// forbid any size which goes over the limit and also limit the aspect ratio to stop people from making too tall or too wide and bypassing the limit.
|
// forbid any size which goes over the limit and also limit the aspect ratio to stop people from making too tall or too wide and bypassing the limit.
|
||||||
// TODO: figure out how to track audio stream quality
|
// TODO: figure out how to track audio stream quality
|
||||||
|
|
||||||
if event.event == "track_published"
|
if event.event == "track_published" {
|
||||||
&& (track.r#type == TrackType::Data as i32
|
let mut disconnect = false;
|
||||||
|| (track.r#type == TrackType::Video as i32
|
|
||||||
&& (user_limits.video_resolution[0] != 0
|
if track.r#type == TrackType::Data as i32 {
|
||||||
|
log::debug!("User published data");
|
||||||
|
disconnect = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if track.r#type == TrackType::Video as i32 {
|
||||||
|
if user_limits.video_resolution[0] != 0
|
||||||
&& user_limits.video_resolution[1] != 0
|
&& user_limits.video_resolution[1] != 0
|
||||||
&& track.width * track.height
|
&& track.width * track.height
|
||||||
> user_limits.video_resolution[0]
|
> user_limits.video_resolution[0] * user_limits.video_resolution[1]
|
||||||
* user_limits.video_resolution[1])
|
|
||||||
|| (user_limits.video_aspect_ratio[0]
|
|
||||||
!= user_limits.video_aspect_ratio[1]
|
|
||||||
&& !(user_limits.video_aspect_ratio[0]
|
|
||||||
..=user_limits.video_aspect_ratio[1])
|
|
||||||
.contains(&(track.width as f32 / track.height as f32)))))
|
|
||||||
{
|
{
|
||||||
|
log::debug!("User published video with out of bounds resolution");
|
||||||
|
disconnect = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if user_limits.video_aspect_ratio[0] != user_limits.video_aspect_ratio[1]
|
||||||
|
&& !(user_limits.video_aspect_ratio[0]..=user_limits.video_aspect_ratio[1])
|
||||||
|
.contains(&(track.width as f32 / track.height as f32))
|
||||||
|
{
|
||||||
|
log::debug!("User published video with out of bounds aspect ratio");
|
||||||
|
disconnect = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if disconnect {
|
||||||
log::debug!("Removing user {user_id} from channel {channel_id} {event:?} due to forbidden track.");
|
log::debug!("Removing user {user_id} from channel {channel_id} {event:?} due to forbidden track.");
|
||||||
|
|
||||||
voice_client.remove_user(node, user_id, channel_id).await?;
|
voice_client.remove_user(node, user_id, channel_id).await?;
|
||||||
delete_voice_state(channel_id, channel.server(), user_id).await?;
|
delete_voice_state(channel_id, channel.server(), user_id).await?;
|
||||||
} else {
|
|
||||||
|
return Ok(EmptyResponse);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
let partial = update_voice_state_tracks(
|
let partial = update_voice_state_tracks(
|
||||||
channel_id,
|
channel_id,
|
||||||
channel.server(),
|
channel.server(),
|
||||||
@@ -250,7 +268,6 @@ pub async fn ingress(
|
|||||||
.p(channel_id.clone())
|
.p(channel_id.clone())
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user