feat: integrate Jitsi configuration and dynamic loading in CallWindow
- Added support for Jitsi configuration retrieval from the backend, allowing for dynamic room name generation based on the active configuration. - Implemented a polyfill for BlobBuilder to ensure compatibility with the lib-jitsi-meet library across different browsers. - Enhanced error handling during the loading of the Jitsi library, providing clearer feedback for missing modules and connection issues. - Updated Vite configuration to exclude lib-jitsi-meet from SSR and allow dynamic loading in the browser. - Introduced a new route for Jitsi settings in the dashboard for user configuration of Jitsi Meet parameters.
This commit is contained in:
@@ -7,6 +7,7 @@ export interface ConfiguracaoJitsi {
|
||||
appId: string;
|
||||
roomPrefix: string;
|
||||
useHttps: boolean;
|
||||
acceptSelfSignedCert?: boolean;
|
||||
}
|
||||
|
||||
export interface DispositivoMedia {
|
||||
@@ -22,9 +23,50 @@ export interface DispositivosDisponiveis {
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter configuração do Jitsi baseada em variáveis de ambiente
|
||||
* Obter configuração do Jitsi do backend ou variáveis de ambiente (fallback)
|
||||
*
|
||||
* @param configBackend - Configuração do backend (opcional). Se fornecida, será usada.
|
||||
* @returns Configuração do Jitsi
|
||||
*/
|
||||
export function obterConfiguracaoJitsi(): ConfiguracaoJitsi {
|
||||
export function obterConfiguracaoJitsi(configBackend?: {
|
||||
domain: string;
|
||||
appId: string;
|
||||
roomPrefix: string;
|
||||
useHttps: boolean;
|
||||
acceptSelfSignedCert?: boolean;
|
||||
} | null): ConfiguracaoJitsi {
|
||||
// Se há configuração do backend e está ativa, usar ela
|
||||
if (configBackend) {
|
||||
return {
|
||||
domain: configBackend.domain,
|
||||
appId: configBackend.appId,
|
||||
roomPrefix: configBackend.roomPrefix,
|
||||
useHttps: configBackend.useHttps,
|
||||
acceptSelfSignedCert: configBackend.acceptSelfSignedCert || false
|
||||
};
|
||||
}
|
||||
|
||||
// Fallback para variáveis de ambiente
|
||||
const domain = import.meta.env.VITE_JITSI_DOMAIN || 'localhost:8443';
|
||||
const appId = import.meta.env.VITE_JITSI_APP_ID || 'sgse-app';
|
||||
const roomPrefix = import.meta.env.VITE_JITSI_ROOM_PREFIX || 'sgse';
|
||||
const useHttps = import.meta.env.VITE_JITSI_USE_HTTPS === 'true' || domain.includes(':8443');
|
||||
const acceptSelfSignedCert = import.meta.env.VITE_JITSI_ACCEPT_SELF_SIGNED === 'true';
|
||||
|
||||
return {
|
||||
domain,
|
||||
appId,
|
||||
roomPrefix,
|
||||
useHttps,
|
||||
acceptSelfSignedCert
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter configuração do Jitsi de forma síncrona (apenas variáveis de ambiente)
|
||||
* Use esta função quando não houver acesso ao Convex client
|
||||
*/
|
||||
export function obterConfiguracaoJitsiSync(): ConfiguracaoJitsi {
|
||||
const domain = import.meta.env.VITE_JITSI_DOMAIN || 'localhost:8443';
|
||||
const appId = import.meta.env.VITE_JITSI_APP_ID || 'sgse-app';
|
||||
const roomPrefix = import.meta.env.VITE_JITSI_ROOM_PREFIX || 'sgse';
|
||||
@@ -49,9 +91,19 @@ export function obterHostEPorta(domain: string): { host: string; porta: number }
|
||||
|
||||
/**
|
||||
* Gerar nome único para a sala Jitsi
|
||||
*
|
||||
* @param conversaId - ID da conversa
|
||||
* @param tipo - Tipo de chamada ('audio' ou 'video')
|
||||
* @param configBackend - Configuração do backend (opcional). Se não fornecida, usa fallback.
|
||||
*/
|
||||
export function gerarRoomName(conversaId: string, tipo: 'audio' | 'video'): string {
|
||||
const config = obterConfiguracaoJitsi();
|
||||
export function gerarRoomName(
|
||||
conversaId: string,
|
||||
tipo: 'audio' | 'video',
|
||||
configBackend?: {
|
||||
roomPrefix: string;
|
||||
} | null
|
||||
): string {
|
||||
const config = obterConfiguracaoJitsi(configBackend || undefined);
|
||||
const timestamp = Date.now();
|
||||
const random = Math.random().toString(36).substring(2, 9);
|
||||
const conversaHash = conversaId.replace(/[^a-zA-Z0-9]/g, '').substring(0, 10);
|
||||
@@ -61,9 +113,18 @@ export function gerarRoomName(conversaId: string, tipo: 'audio' | 'video'): stri
|
||||
|
||||
/**
|
||||
* Obter URL completa da sala Jitsi
|
||||
*
|
||||
* @param roomName - Nome da sala Jitsi
|
||||
* @param configBackend - Configuração do backend (opcional). Se não fornecida, usa fallback.
|
||||
*/
|
||||
export function obterUrlSala(roomName: string): string {
|
||||
const config = obterConfiguracaoJitsi();
|
||||
export function obterUrlSala(
|
||||
roomName: string,
|
||||
configBackend?: {
|
||||
domain: string;
|
||||
useHttps: boolean;
|
||||
} | null
|
||||
): string {
|
||||
const config = obterConfiguracaoJitsi(configBackend || undefined);
|
||||
const protocol = config.useHttps ? 'https' : 'http';
|
||||
return `${protocol}://${config.domain}/${roomName}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user