Connection With Omega

This commit is contained in:
Alex Emmet 2026-01-05 02:17:12 +01:00
commit 504e5ff015
20 changed files with 880 additions and 320 deletions

View file

@ -2,7 +2,11 @@ use livekit_api::access_token;
use std::env;
use uuid::Uuid;
pub fn create_token(user_id: i64, call_id: Uuid) -> Result<String, access_token::AccessTokenError> {
pub fn create_token(
user_id: i64,
call_id: Uuid,
has_admin: bool,
) -> Result<String, access_token::AccessTokenError> {
let api_key = env::var("LIVEKIT_API_KEY").expect("LIVEKIT_API_KEY is not set");
let api_secret = env::var("LIVEKIT_API_SECRET").expect("LIVEKIT_API_SECRET is not set");
@ -11,9 +15,11 @@ pub fn create_token(user_id: i64, call_id: Uuid) -> Result<String, access_token:
.with_grants(access_token::VideoGrants {
can_update_own_metadata: true,
room_join: true,
room_admin: has_admin,
room: call_id.to_string(),
..Default::default()
})
.with_metadata(&format!("{{\"isAdmin\":{}}}", has_admin))
.to_jwt();
return token;
}