diff --git a/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts index 2ba05b8..7e32a27 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts @@ -21,7 +21,6 @@ import { OutboundEventMessage } from 'webcomponent/src/models/message.type'; import { AuthService, ContextService, - HttpService, RoomService, SessionStorageService, WebComponentManagerService @@ -85,7 +84,6 @@ export class VideoRoomComponent implements OnInit, OnDestroy { }; constructor( - protected httpService: HttpService, protected navigationService: NavigationService, protected participantTokenService: ParticipantTokenService, protected recManagerService: RecordingManagerService, @@ -203,7 +201,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy { // and replace the secret in the URL with the publisher secret if (this.participantRole === ParticipantRole.MODERATOR) { try { - const { moderatorSecret, publisherSecret } = await this.getRoomSecrets(); + const { moderatorSecret, publisherSecret } = await this.roomService.getSecrets(this.roomId); this.sessionStorageService.setModeratorSecret(this.roomId, moderatorSecret); secretQueryParam = publisherSecret; } 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() { await this.navigationService.goToRecordings(this.roomId, this.roomSecret); } diff --git a/frontend/projects/shared-meet-components/src/lib/services/room/room.service.ts b/frontend/projects/shared-meet-components/src/lib/services/room/room.service.ts index 1dd5a71..fcde9e6 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/room/room.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/room/room.service.ts @@ -49,6 +49,27 @@ export class RoomService { 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. *