backend: Add error handling for invalid room secrets and update related service logic
This commit is contained in:
parent
ba3c01eaae
commit
0e580e6257
@ -104,20 +104,17 @@ export const isErrorRecordingCannotBeStoppedWhileStarting = (
|
||||
};
|
||||
|
||||
// Room errors
|
||||
|
||||
export const errorRoomNotFound = (roomId: string): OpenViduMeetError => {
|
||||
return new OpenViduMeetError('Room Error', `The room '${roomId}' does not exist`, 404);
|
||||
};
|
||||
|
||||
// Participant errors
|
||||
|
||||
export const errorParticipantUnauthorized = (roomId: string): OpenViduMeetError => {
|
||||
return new OpenViduMeetError(
|
||||
'Participant Error',
|
||||
`Unauthorized generating token with received credentials in room '${roomId}'`,
|
||||
406
|
||||
);
|
||||
export const errorInvalidRoomSecret = (roomId: string, secret: string): OpenViduMeetError => {
|
||||
return new OpenViduMeetError('Room Error', `The secret '${secret}' is not recognized for room '${roomId}'`, 400);
|
||||
};
|
||||
|
||||
// Participant errors
|
||||
|
||||
export const errorParticipantNotFound = (participantName: string, roomId: string): OpenViduMeetError => {
|
||||
return new OpenViduMeetError('Participant Error', `'${participantName}' not found in room '${roomId}'`, 404);
|
||||
};
|
||||
|
||||
@ -8,7 +8,7 @@ import { MeetRoom, MeetRoomFilters, MeetRoomOptions, MeetRoomPreferences, Partic
|
||||
import { MeetRoomHelper } from '../helpers/room.helper.js';
|
||||
import { SystemEventService } from './system-event.service.js';
|
||||
import { IScheduledTask, TaskSchedulerService } from './task-scheduler.service.js';
|
||||
import { errorParticipantUnauthorized, internalError } from '../models/error.model.js';
|
||||
import { errorInvalidRoomSecret, internalError } from '../models/error.model.js';
|
||||
import { OpenViduComponentsAdapterHelper } from '../helpers/index.js';
|
||||
import { uid } from 'uid/single';
|
||||
import { MEET_NAME_ID } from '../environment.js';
|
||||
@ -242,7 +242,7 @@ export class RoomService {
|
||||
case publisherSecret:
|
||||
return ParticipantRole.PUBLISHER;
|
||||
default:
|
||||
throw errorParticipantUnauthorized(roomId);
|
||||
throw errorInvalidRoomSecret(roomId, secret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user