Skip to content

Commit

Permalink
fix: respond with the url when joining a voice channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomatree committed Feb 17, 2025
1 parent 9511280 commit 9c2cc87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions crates/core/models/src/v0/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ auto_derived!(
pub struct CreateVoiceUserResponse {
/// Token for authenticating with the voice server
pub token: String,
/// Url of the livekit server to connect to
pub url: String
}

/// Voice state for a channel
Expand Down
10 changes: 6 additions & 4 deletions crates/delta/src/routes/channels/voice_join.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use revolt_config::config;
use revolt_models::v0;
use revolt_database::{util::{permissions::perms, reference::Reference}, voice::{raise_if_in_voice, VoiceClient}, Channel, Database, SystemMessage, User, AMQP};
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
Expand All @@ -11,9 +12,10 @@ use rocket::{serde::json::Json, State};
#[openapi(tag = "Voice")]
#[post("/<target>/join_call", data="<data>")]
pub async fn call(db: &State<Database>, amqp: &State<AMQP>, voice: &State<VoiceClient>, user: User, target: Reference, data: Json<v0::DataJoinCall>) -> Result<Json<v0::CreateVoiceUserResponse>> {
if !voice.rooms.contains_key(&data.node) {
return Err(create_error!(UnknownNode))
}
let config = config().await;

let node_host = config.hosts.livekit.get(&data.node)
.ok_or_else(|| create_error!(UnknownNode))?;

let channel = target.as_channel(db).await?;

Expand Down Expand Up @@ -50,5 +52,5 @@ pub async fn call(db: &State<Database>, amqp: &State<AMQP>, voice: &State<VoiceC
_ => {}
};

Ok(Json(v0::CreateVoiceUserResponse { token }))
Ok(Json(v0::CreateVoiceUserResponse { token, url: node_host.clone() }))
}

0 comments on commit 9c2cc87

Please sign in to comment.