backend: Include room existence check in endMeeting function

This commit is contained in:
juancarmore 2025-04-14 12:47:08 +02:00
parent e3ee41c827
commit 7bcb3be1dd
3 changed files with 14 additions and 6 deletions

View File

@ -19,8 +19,8 @@
$ref: '../../components/responses/unauthorized-error.yaml'
'403':
$ref: '../../components/responses/forbidden-error.yaml'
# '404':
# $ref: '../../components/responses/error-room-not-found.yaml'
'404':
$ref: '../../components/responses/error-room-not-found.yaml'
'500':
$ref: '../../components/responses/internal-server-error.yaml'
/meetings/{roomId}/participants/{participantName}:

View File

@ -1,14 +1,23 @@
import { container } from '../config/dependency-injector.config.js';
import { Request, Response } from 'express';
import { LoggerService } from '../services/logger.service.js';
import { OpenViduMeetError } from '../models/index.js';
import { LiveKitService } from '../services/livekit.service.js';
import { LoggerService, RoomService, LiveKitService } from '../services/index.js';
export const endMeeting = async (req: Request, res: Response) => {
const logger = container.get(LoggerService);
const roomService = container.get(RoomService);
const livekitService = container.get(LiveKitService);
const { roomId } = req.params;
// Check if the room exists
try {
await roomService.getMeetRoom(roomId);
} catch (error) {
logger.error(`Error getting room '${roomId}'`);
return handleError(res, error);
}
try {
// To end a meeting, we need to delete the room from LiveKit
await livekitService.deleteRoom(roomId);

View File

@ -123,8 +123,7 @@ export const getRoomRolesAndPermissions = async (req: Request, res: Response) =>
await roomService.getMeetRoom(roomId);
} catch (error) {
logger.error(`Error getting room '${roomId}'`);
handleError(res, error);
return;
return handleError(res, error);
}
logger.verbose(`Getting roles and associated permissions for room '${roomId}'`);