frontend: Provides adapter interfaces for shared guards

Creates adapter interfaces for meeting context and room member operations.

This allows shared guards to interact with meeting context and room member context without directly depending on domain services, improving modularity and testability.

Adds providers to supply the adapters using existing services, enabling the use of the adapter interface within the guards.
This commit is contained in:
Carlos Santos 2026-01-14 11:37:33 +01:00
parent 3eb06e41e2
commit db62cf0e1c
12 changed files with 91 additions and 11 deletions

View File

@ -2,4 +2,6 @@ export * from './components';
export * from './customization';
export * from './models';
export * from './pages';
export * from './providers';
export * from './services';

View File

@ -0,0 +1 @@
export * from './meeting-context-adapter.provider';

View File

@ -0,0 +1,12 @@
import { Provider } from '@angular/core';
import { MEETING_CONTEXT_ADAPTER } from '../../../shared/adapters';
import { MeetingContextService } from '../services/meeting-context.service';
/**
* Provides the MeetingContextAdapter using the existing MeetingContextService.
* This allows shared guards to use the adapter interface without depending on domain services.
*/
export const MEETING_CONTEXT_ADAPTER_PROVIDER: Provider = {
provide: MEETING_CONTEXT_ADAPTER,
useExisting: MeetingContextService
};

View File

@ -3,5 +3,6 @@ export * from './guards';
export * from './interceptor-handlers';
export * from './models';
export * from './pages';
export * from './providers';
export * from './services';

View File

@ -0,0 +1 @@
export * from './room-member-adapter.provider';

View File

@ -0,0 +1,12 @@
import { Provider } from '@angular/core';
import { ROOM_MEMBER_ADAPTER } from '../../../shared/adapters';
import { RoomMemberService } from '../services/room-member.service';
/**
* Provides the RoomMemberAdapter using the existing RoomMemberService.
* This allows shared guards to use the adapter interface without depending on domain services.
*/
export const ROOM_MEMBER_ADAPTER_PROVIDER: Provider = {
provide: ROOM_MEMBER_ADAPTER,
useExisting: RoomMemberService
};

View File

@ -0,0 +1,3 @@
export * from './meeting-context.adapter';
export * from './room-member.adapter';

View File

@ -0,0 +1,27 @@
import { InjectionToken } from '@angular/core';
/**
* Adapter interface for meeting context operations.
* This allows shared guards to interact with meeting context without directly depending on domain services.
*/
export interface MeetingContextAdapter {
/**
* Sets the room ID for the current meeting context
*/
setRoomId(roomId: string): void;
/**
* Sets the room secret for the current meeting context
*/
setRoomSecret(secret: string, persistInStorage?: boolean): void;
/**
* Sets the E2EE encryption key for the current meeting
*/
setE2eeKey(key: string): void;
}
/**
* Injection token for the MeetingContextAdapter
*/
export const MEETING_CONTEXT_ADAPTER = new InjectionToken<MeetingContextAdapter>('MEETING_CONTEXT_ADAPTER');

View File

@ -0,0 +1,17 @@
import { InjectionToken } from '@angular/core';
/**
* Adapter interface for room member operations.
* This allows shared guards to interact with room member context without directly depending on domain services.
*/
export interface RoomMemberAdapter {
/**
* Sets the participant name for the current room member
*/
setParticipantName(name: string): void;
}
/**
* Injection token for the RoomMemberAdapter
*/
export const ROOM_MEMBER_ADAPTER = new InjectionToken<RoomMemberAdapter>('ROOM_MEMBER_ADAPTER');

View File

@ -1,8 +1,7 @@
import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivateFn } from '@angular/router';
import { WebComponentProperty } from '@openvidu-meet/typings';
import { MeetingContextService } from '../../domains/meeting/services/meeting-context.service';
import { RoomMemberService } from '../../domains/rooms/services/room-member.service';
import { MEETING_CONTEXT_ADAPTER, ROOM_MEMBER_ADAPTER } from '../adapters';
import { NavigationErrorReason } from '../models/navigation.model';
import { AppDataService } from '../services/app-data.service';
import { NavigationService } from '../services/navigation.service';
@ -10,8 +9,8 @@ import { SessionStorageService } from '../services/session-storage.service';
export const extractRoomQueryParamsGuard: CanActivateFn = (route: ActivatedRouteSnapshot) => {
const navigationService = inject(NavigationService);
const meetingContextService = inject(MeetingContextService);
const roomMemberService = inject(RoomMemberService);
const meetingContextAdapter = inject(MEETING_CONTEXT_ADAPTER);
const roomMemberAdapter = inject(ROOM_MEMBER_ADAPTER);
const sessionStorageService = inject(SessionStorageService);
const {
@ -33,15 +32,15 @@ export const extractRoomQueryParamsGuard: CanActivateFn = (route: ActivatedRoute
return navigationService.redirectToErrorPage(NavigationErrorReason.MISSING_ROOM_SECRET);
}
meetingContextService.setRoomId(roomId);
meetingContextService.setRoomSecret(secret, true);
meetingContextAdapter.setRoomId(roomId);
meetingContextAdapter.setRoomSecret(secret, true);
if (e2eeKey) {
meetingContextService.setE2eeKey(e2eeKey);
meetingContextAdapter.setE2eeKey(e2eeKey);
}
if (participantName) {
roomMemberService.setParticipantName(participantName);
roomMemberAdapter.setParticipantName(participantName);
}
if (showOnlyRecordings === 'true') {
@ -54,7 +53,7 @@ export const extractRoomQueryParamsGuard: CanActivateFn = (route: ActivatedRoute
export const extractRecordingQueryParamsGuard: CanActivateFn = (route: ActivatedRouteSnapshot) => {
const navigationService = inject(NavigationService);
const meetingContextService = inject(MeetingContextService);
const meetingContextAdapter = inject(MEETING_CONTEXT_ADAPTER);
const sessionStorageService = inject(SessionStorageService);
const { roomId, secret: querySecret } = extractParams(route);
@ -65,8 +64,8 @@ export const extractRecordingQueryParamsGuard: CanActivateFn = (route: Activated
return navigationService.redirectToErrorPage(NavigationErrorReason.MISSING_ROOM_SECRET);
}
meetingContextService.setRoomId(roomId);
meetingContextService.setRoomSecret(secret, true);
meetingContextAdapter.setRoomId(roomId);
meetingContextAdapter.setRoomSecret(secret, true);
return true;
};

View File

@ -1,3 +1,4 @@
export * from './adapters';
export * from './components';
export * from './guards';
export * from './interceptors';

View File

@ -15,7 +15,9 @@ import {
AuthInterceptorErrorHandlerService,
CustomParticipantModel,
httpInterceptor,
MEETING_CONTEXT_ADAPTER_PROVIDER,
MeetingLayoutService,
ROOM_MEMBER_ADAPTER_PROVIDER,
RoomMemberInterceptorErrorHandlerService,
ThemeService
} from '@openvidu-meet/shared-components';
@ -44,6 +46,8 @@ export const appConfig: ApplicationConfig = {
provideAppInitializer(() => inject(RoomMemberInterceptorErrorHandlerService).init()),
importProvidersFrom(OpenViduComponentsModule.forRoot(ovComponentsconfig)),
{ provide: LayoutService, useClass: MeetingLayoutService },
MEETING_CONTEXT_ADAPTER_PROVIDER,
ROOM_MEMBER_ADAPTER_PROVIDER,
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(ceRoutes),
provideAnimationsAsync(),