backend: Rename getRoomSecretRole to getRoomRoleBySecret and update related calls

This commit is contained in:
juancarmore 2025-04-12 13:45:34 +02:00
parent 81db83129b
commit cc2dc83401
4 changed files with 4 additions and 17 deletions

View File

@ -34,7 +34,6 @@ export class MeetRoomHelper {
static extractSecretsFromRoom(room: MeetRoom): { publisherSecret: string; moderatorSecret: string } {
const { publisherRoomUrl, moderatorRoomUrl } = room;
const publisherUrl = new URL(publisherRoomUrl);
const publisherSecret = publisherUrl.searchParams.get('secret') || '';
const moderatorUrl = new URL(moderatorRoomUrl);

View File

@ -20,7 +20,7 @@ export const configureTokenAuth = async (req: Request, res: Response, next: Next
try {
const { roomId, secret } = req.body as TokenOptions;
role = await roomService.getRoomSecretRole(roomId, secret);
role = await roomService.getRoomRoleBySecret(roomId, secret);
} catch (error) {
logger.error('Error getting room secret role', error);
return res.status(500).json({ message: 'Internal server error' });

View File

@ -30,7 +30,7 @@ export class ParticipantService {
throw errorParticipantNotFound(participantName, roomId);
}
const role = await this.roomService.getRoomSecretRole(roomId, secret);
const role = await this.roomService.getRoomRoleBySecret(roomId, secret);
const token = await this.generateParticipantToken(role, options);
this.logger.verbose(`Participant token generated for room ${roomId}`);
return token;

View File

@ -232,21 +232,9 @@ export class RoomService {
* @throws Error if the moderator or publisher secrets cannot be extracted from their URLs
* @throws Error if the provided secret doesn't match any of the room's secrets (unauthorized)
*/
async getRoomSecretRole(roomId: string, secret: string): Promise<ParticipantRole> {
async getRoomRoleBySecret(roomId: string, secret: string): Promise<ParticipantRole> {
const room = await this.getMeetRoom(roomId);
const { moderatorRoomUrl, publisherRoomUrl } = room;
const extractSecret = (urlString: string, type: string): string => {
const url = new URL(urlString);
const secret = url.searchParams.get('secret');
if (!secret) throw new Error(`${type} secret not found`);
return secret;
};
const publisherSecret = extractSecret(publisherRoomUrl, 'Publisher');
const moderatorSecret = extractSecret(moderatorRoomUrl, 'Moderator');
const { moderatorSecret, publisherSecret } = MeetRoomHelper.extractSecretsFromRoom(room);
switch (secret) {
case moderatorSecret: