frontend: remove HttpService dependency from VideoRoomComponent and move getSecrets method to RoomService

This commit is contained in:
Carlos Santos 2025-06-09 13:46:38 +02:00
parent 2aa3bc1177
commit df0089c323
2 changed files with 22 additions and 13 deletions

View File

@ -21,7 +21,6 @@ import { OutboundEventMessage } from 'webcomponent/src/models/message.type';
import { import {
AuthService, AuthService,
ContextService, ContextService,
HttpService,
RoomService, RoomService,
SessionStorageService, SessionStorageService,
WebComponentManagerService WebComponentManagerService
@ -85,7 +84,6 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
}; };
constructor( constructor(
protected httpService: HttpService,
protected navigationService: NavigationService, protected navigationService: NavigationService,
protected participantTokenService: ParticipantTokenService, protected participantTokenService: ParticipantTokenService,
protected recManagerService: RecordingManagerService, protected recManagerService: RecordingManagerService,
@ -203,7 +201,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
// and replace the secret in the URL with the publisher secret // and replace the secret in the URL with the publisher secret
if (this.participantRole === ParticipantRole.MODERATOR) { if (this.participantRole === ParticipantRole.MODERATOR) {
try { try {
const { moderatorSecret, publisherSecret } = await this.getRoomSecrets(); const { moderatorSecret, publisherSecret } = await this.roomService.getSecrets(this.roomId);
this.sessionStorageService.setModeratorSecret(this.roomId, moderatorSecret); this.sessionStorageService.setModeratorSecret(this.roomId, moderatorSecret);
secretQueryParam = publisherSecret; secretQueryParam = publisherSecret;
} catch (error) { } catch (error) {
@ -218,16 +216,6 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
}); });
} }
private async getRoomSecrets(): Promise<{ moderatorSecret: string; publisherSecret: string }> {
const { moderatorRoomUrl, publisherRoomUrl } = await this.httpService.getRoom(this.roomId);
const publisherUrl = new URL(publisherRoomUrl);
const publisherSecret = publisherUrl.searchParams.get('secret') || '';
const moderatorUrl = new URL(moderatorRoomUrl);
const moderatorSecret = moderatorUrl.searchParams.get('secret') || '';
return { publisherSecret, moderatorSecret };
}
async goToRecordings() { async goToRecordings() {
await this.navigationService.goToRecordings(this.roomId, this.roomSecret); await this.navigationService.goToRecordings(this.roomId, this.roomSecret);
} }

View File

@ -49,6 +49,27 @@ export class RoomService {
return this.roomPreferences; return this.roomPreferences;
} }
/**
* Retrieves the moderator and publisher secrets for a specified room.
*
* This method fetches room information and extracts the secret parameters
* from the moderator and publisher room URLs.
*
* @param roomId - The unique identifier of the room
* @returns A promise that resolves to an object containing both secrets
* @returns moderatorSecret - The secret parameter extracted from the moderator room URL
* @returns publisherSecret - The secret parameter extracted from the publisher room URL
*/
async getSecrets(roomId: string): Promise<{ moderatorSecret: string; publisherSecret: string }> {
const { moderatorRoomUrl, publisherRoomUrl } = await this.httpService.getRoom(roomId);
const publisherUrl = new URL(publisherRoomUrl);
const publisherSecret = publisherUrl.searchParams.get('secret') || '';
const moderatorUrl = new URL(moderatorRoomUrl);
const moderatorSecret = moderatorUrl.searchParams.get('secret') || '';
return { publisherSecret, moderatorSecret };
}
/** /**
* Saves the room preferences. * Saves the room preferences.
* *