backend: remove roomService dependency from generateParticipantToken and ensure Livekit room creation in ParticipantService
This commit is contained in:
parent
2475f7a8e2
commit
1af8f77b7b
@ -14,7 +14,6 @@ import { getCookieOptions } from '../utils/cookie-utils.js';
|
|||||||
export const generateParticipantToken = async (req: Request, res: Response) => {
|
export const generateParticipantToken = async (req: Request, res: Response) => {
|
||||||
const logger = container.get(LoggerService);
|
const logger = container.get(LoggerService);
|
||||||
const participantService = container.get(ParticipantService);
|
const participantService = container.get(ParticipantService);
|
||||||
const roomService = container.get(RoomService);
|
|
||||||
const participantOptions: ParticipantOptions = req.body;
|
const participantOptions: ParticipantOptions = req.body;
|
||||||
const { roomId } = participantOptions;
|
const { roomId } = participantOptions;
|
||||||
|
|
||||||
@ -40,11 +39,6 @@ export const generateParticipantToken = async (req: Request, res: Response) => {
|
|||||||
try {
|
try {
|
||||||
logger.verbose(`Generating participant token for room '${roomId}'`);
|
logger.verbose(`Generating participant token for room '${roomId}'`);
|
||||||
|
|
||||||
// If participantName is provided, create the Livekit room if it doesn't exist
|
|
||||||
if (participantOptions.participantName) {
|
|
||||||
await roomService.createLivekitRoom(roomId);
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = await participantService.generateOrRefreshParticipantToken(participantOptions, currentRoles);
|
const token = await participantService.generateOrRefreshParticipantToken(participantOptions, currentRoles);
|
||||||
res.cookie(INTERNAL_CONFIG.PARTICIPANT_TOKEN_COOKIE_NAME, token, getCookieOptions('/'));
|
res.cookie(INTERNAL_CONFIG.PARTICIPANT_TOKEN_COOKIE_NAME, token, getCookieOptions('/'));
|
||||||
return res.status(200).json({ token });
|
return res.status(200).json({ token });
|
||||||
|
|||||||
@ -52,6 +52,9 @@ export class ParticipantService {
|
|||||||
throw errorRoomClosed(roomId);
|
throw errorRoomClosed(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the Livekit room if it doesn't exist
|
||||||
|
await this.roomService.createLivekitRoom(roomId);
|
||||||
|
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
if (!participantIdentity) {
|
if (!participantIdentity) {
|
||||||
throw errorParticipantIdentityNotProvided();
|
throw errorParticipantIdentityNotProvided();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user