backend: simplify participant identity generation by using participant name directly
This commit is contained in:
parent
ca90a03b9a
commit
e1fd2a343b
@ -9,10 +9,7 @@ import { inject, injectable } from 'inversify';
|
|||||||
import { ParticipantInfo } from 'livekit-server-sdk';
|
import { ParticipantInfo } from 'livekit-server-sdk';
|
||||||
import { MeetRoomHelper } from '../helpers/room.helper.js';
|
import { MeetRoomHelper } from '../helpers/room.helper.js';
|
||||||
import { validateMeetTokenMetadata } from '../middlewares/index.js';
|
import { validateMeetTokenMetadata } from '../middlewares/index.js';
|
||||||
import {
|
import { errorParticipantIdentityNotProvided, errorParticipantNotFound } from '../models/error.model.js';
|
||||||
errorParticipantIdentityNotProvided,
|
|
||||||
errorParticipantNotFound
|
|
||||||
} from '../models/error.model.js';
|
|
||||||
import {
|
import {
|
||||||
FrontendEventService,
|
FrontendEventService,
|
||||||
LiveKitService,
|
LiveKitService,
|
||||||
@ -81,7 +78,10 @@ export class ParticipantService {
|
|||||||
|
|
||||||
const role = await this.roomService.getRoomRoleBySecret(roomId, secret);
|
const role = await this.roomService.getRoomRoleBySecret(roomId, secret);
|
||||||
const token = await this.generateParticipantToken(finalParticipantOptions, role, currentRoles);
|
const token = await this.generateParticipantToken(finalParticipantOptions, role, currentRoles);
|
||||||
this.logger.verbose(`Participant token generated for room '${roomId}' with name '${finalParticipantName}'`);
|
this.logger.verbose(
|
||||||
|
`Participant token generated for room '${roomId}'` +
|
||||||
|
(finalParticipantName ? ` with name '${finalParticipantName}'` : '')
|
||||||
|
);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,9 +55,7 @@ export class TokenService {
|
|||||||
let { participantIdentity } = participantOptions;
|
let { participantIdentity } = participantOptions;
|
||||||
|
|
||||||
if (participantName && !participantIdentity) {
|
if (participantName && !participantIdentity) {
|
||||||
// Generate participant identity based on name and unique ID
|
participantIdentity = participantName;
|
||||||
const identityPrefix = participantName.replace(/\s+/g, ''); // Remove all spaces
|
|
||||||
participantIdentity = `${identityPrefix}-${uid(8)}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const metadata: MeetTokenMetadata = {
|
const metadata: MeetTokenMetadata = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user