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
|
// Room errors
|
||||||
|
|
||||||
export const errorRoomNotFound = (roomId: string): OpenViduMeetError => {
|
export const errorRoomNotFound = (roomId: string): OpenViduMeetError => {
|
||||||
return new OpenViduMeetError('Room Error', `The room '${roomId}' does not exist`, 404);
|
return new OpenViduMeetError('Room Error', `The room '${roomId}' does not exist`, 404);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Participant errors
|
export const errorInvalidRoomSecret = (roomId: string, secret: string): OpenViduMeetError => {
|
||||||
|
return new OpenViduMeetError('Room Error', `The secret '${secret}' is not recognized for room '${roomId}'`, 400);
|
||||||
export const errorParticipantUnauthorized = (roomId: string): OpenViduMeetError => {
|
|
||||||
return new OpenViduMeetError(
|
|
||||||
'Participant Error',
|
|
||||||
`Unauthorized generating token with received credentials in room '${roomId}'`,
|
|
||||||
406
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Participant errors
|
||||||
|
|
||||||
export const errorParticipantNotFound = (participantName: string, roomId: string): OpenViduMeetError => {
|
export const errorParticipantNotFound = (participantName: string, roomId: string): OpenViduMeetError => {
|
||||||
return new OpenViduMeetError('Participant Error', `'${participantName}' not found in room '${roomId}'`, 404);
|
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 { MeetRoomHelper } from '../helpers/room.helper.js';
|
||||||
import { SystemEventService } from './system-event.service.js';
|
import { SystemEventService } from './system-event.service.js';
|
||||||
import { IScheduledTask, TaskSchedulerService } from './task-scheduler.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 { OpenViduComponentsAdapterHelper } from '../helpers/index.js';
|
||||||
import { uid } from 'uid/single';
|
import { uid } from 'uid/single';
|
||||||
import { MEET_NAME_ID } from '../environment.js';
|
import { MEET_NAME_ID } from '../environment.js';
|
||||||
@ -242,7 +242,7 @@ export class RoomService {
|
|||||||
case publisherSecret:
|
case publisherSecret:
|
||||||
return ParticipantRole.PUBLISHER;
|
return ParticipantRole.PUBLISHER;
|
||||||
default:
|
default:
|
||||||
throw errorParticipantUnauthorized(roomId);
|
throw errorInvalidRoomSecret(roomId, secret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user