chore: switch to ids for parameter

This commit is contained in:
Zomatree
2025-02-02 13:46:45 +00:00
parent 742eb3bb7d
commit 2593a4272b
8 changed files with 26 additions and 17 deletions

View File

@@ -106,8 +106,8 @@ impl VoiceClient {
.to_internal_error()
}
pub async fn remove_user(&self, user: &User, channel_id: &str) -> Result<()> {
self.rooms.remove_participant(channel_id, &user.id)
pub async fn remove_user(&self, user_id: &str, channel_id: &str) -> Result<()> {
self.rooms.remove_participant(channel_id, user_id)
.await
.to_internal_error()
}

View File

@@ -1,11 +1,11 @@
# Build Stage
FROM ghcr.io/revoltchat/base:latest AS builder
FROM debian:12 AS debian
# Bundle Stage
FROM debian:bullseye-slim
RUN apt-get update && \
apt-get install -y ca-certificates && \
apt-get clean
FROM gcr.io/distroless/cc-debian12:nonroot
COPY --from=builder /home/rust/src/target/release/revolt-voice-ingress ./
EXPOSE 9000
CMD ["./revolt-voice-ingress"]
COPY --from=debian /usr/bin/uname /usr/bin/uname
USER nonroot
CMD ["./revolt-voice-ingress"]

View File

@@ -1,7 +1,7 @@
use std::env;
use livekit_protocol::WebhookEvent;
use livekit_protocol::{TrackType, WebhookEvent};
use revolt_database::{
events::client::EventV1, util::reference::Reference, Database, DatabaseInfo,
voice::{create_voice_state, delete_voice_state, update_voice_state_tracks, VoiceClient}
@@ -85,6 +85,17 @@ async fn ingress(db: &State<Database>, voice_client: &State<VoiceClient>, body:
.as_channel(db)
.await?;
// remove the user if they try publish a video larger than 1080x720 or they publish data
if body.event == "track_published"
&& (
(track.r#type == TrackType::Video as i32 && (track.width > 1080 || track.height > 720))
| (track.r#type == TrackType::Data as i32)
)
{
voice_client.remove_user(user_id, channel_id).await?;
delete_voice_state(channel_id, channel.server().as_deref(), user_id).await?;
}
let partial = update_voice_state_tracks(
channel_id,
channel.server().as_deref(),

View File

@@ -54,9 +54,7 @@ pub async fn delete(
};
for user_id in get_voice_channel_members(channel.id()).await? {
let user = Reference::from_unchecked(user_id).as_user(db).await?;
voice_client.remove_user(&user, channel.id()).await?;
voice_client.remove_user(&user_id, channel.id()).await?;
delete_voice_state(channel.id(), channel.server().as_deref(), &user.id).await?;
};

View File

@@ -48,7 +48,7 @@ pub async fn remove_member(
};
if is_in_voice_channel(&user.id, channel.id()).await? {
voice_client.remove_user(&user, channel.id()).await?;
voice_client.remove_user(&user.id, channel.id()).await?;
delete_voice_state(channel.id(), None, &user.id).await?;
};

View File

@@ -61,7 +61,7 @@ pub async fn ban(
// If the member is in a voice channel while banned kick them from the voice channel
if let Some(channel_id) = get_user_voice_channel_in_server(&user.id, &server.id).await? {
voice_client.remove_user(&user, &channel_id).await?;
voice_client.remove_user(&user.id, &channel_id).await?;
delete_voice_state(&channel_id, Some(&server.id), &user.id).await?
}
}

View File

@@ -43,7 +43,7 @@ pub async fn kick(
}
if let Some(channel_id) = get_user_voice_channel_in_server(&user.id, &server.id).await? {
voice_client.remove_user(&user, &channel_id).await?;
voice_client.remove_user(&user.id, &channel_id).await?;
delete_voice_state(&channel_id, Some(&server.id), &user.id).await?;
}

View File

@@ -26,7 +26,7 @@ pub async fn delete(
if server.owner == user.id {
for channel_id in &server.channels {
voice_client.remove_user(&user, channel_id).await?;
voice_client.remove_user(&user.id, channel_id).await?;
delete_voice_state(channel_id, Some(&server.id), &user.id).await?;
}
@@ -34,7 +34,7 @@ pub async fn delete(
} else {
if let Some(channel_id) = get_user_voice_channel_in_server(&user.id, &server.id).await? {
if server.channels.iter().any(|c| c == &channel_id) {
voice_client.remove_user(&user, &channel_id).await?;
voice_client.remove_user(&user.id, &channel_id).await?;
delete_voice_state(&channel_id, Some(&server.id), &user.id).await?;
}
};