backend: update room preferences endpoint and move get room preferences endpoint to public API
This commit is contained in:
parent
b89ee91794
commit
3322723b8d
@ -119,17 +119,32 @@ export const bulkDeleteRooms = async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getRoomPreferences = async (req: Request, res: Response) => {
|
||||||
|
const logger = container.get(LoggerService);
|
||||||
|
const roomService = container.get(RoomService);
|
||||||
|
const { roomId } = req.params;
|
||||||
|
|
||||||
|
logger.verbose(`Getting room preferences for room '${roomId}'`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { preferences } = await roomService.getMeetRoom(roomId);
|
||||||
|
return res.status(200).json(preferences);
|
||||||
|
} catch (error) {
|
||||||
|
handleError(res, error, `getting room preferences for room '${roomId}'`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const updateRoomPreferences = async (req: Request, res: Response) => {
|
export const updateRoomPreferences = async (req: Request, res: Response) => {
|
||||||
const logger = container.get(LoggerService);
|
const logger = container.get(LoggerService);
|
||||||
const roomService = container.get(RoomService);
|
const roomService = container.get(RoomService);
|
||||||
const roomPreferences = req.body;
|
const { preferences } = req.body;
|
||||||
const { roomId } = req.params;
|
const { roomId } = req.params;
|
||||||
|
|
||||||
logger.verbose(`Updating room preferences for room '${roomId}'`);
|
logger.verbose(`Updating room preferences for room '${roomId}'`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const room = await roomService.updateMeetRoomPreferences(roomId, roomPreferences);
|
await roomService.updateMeetRoomPreferences(roomId, preferences);
|
||||||
return res.status(200).json(room);
|
return res.status(200).json({ message: `Room preferences for room '${roomId}' updated successfully` });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(res, error, `updating room preferences for room '${roomId}'`);
|
handleError(res, error, `updating room preferences for room '${roomId}'`);
|
||||||
}
|
}
|
||||||
@ -209,18 +224,3 @@ export const getRoomRoleAndPermissions = async (req: Request, res: Response) =>
|
|||||||
handleError(res, error, `getting room role and permissions for room '${roomId}' and secret '${secret}'`);
|
handleError(res, error, `getting room role and permissions for room '${roomId}' and secret '${secret}'`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRoomPreferences = async (req: Request, res: Response) => {
|
|
||||||
const logger = container.get(LoggerService);
|
|
||||||
const roomService = container.get(RoomService);
|
|
||||||
const { roomId } = req.params;
|
|
||||||
|
|
||||||
logger.verbose(`Getting room preferences for room '${roomId}'`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const { preferences } = await roomService.getMeetRoom(roomId);
|
|
||||||
return res.status(200).json(preferences);
|
|
||||||
} catch (error) {
|
|
||||||
handleError(res, error, `getting room preferences for room '${roomId}'`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
@ -184,6 +184,10 @@ const BulkDeleteRoomsSchema = z.object({
|
|||||||
force: validForceQueryParam()
|
force: validForceQueryParam()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const UpdateRoomPreferencesSchema = z.object({
|
||||||
|
preferences: RoomPreferencesSchema
|
||||||
|
});
|
||||||
|
|
||||||
const RecordingTokenRequestSchema = z.object({
|
const RecordingTokenRequestSchema = z.object({
|
||||||
secret: z.string().nonempty('Secret is required')
|
secret: z.string().nonempty('Secret is required')
|
||||||
});
|
});
|
||||||
@ -224,7 +228,7 @@ export const withValidRoomFiltersRequest = (req: Request, res: Response, next: N
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const withValidRoomPreferences = (req: Request, res: Response, next: NextFunction) => {
|
export const withValidRoomPreferences = (req: Request, res: Response, next: NextFunction) => {
|
||||||
const { success, error, data } = RoomPreferencesSchema.safeParse(req.body);
|
const { success, error, data } = UpdateRoomPreferencesSchema.safeParse(req.body);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return rejectUnprocessableRequest(res, error);
|
return rejectUnprocessableRequest(res, error);
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import * as roomCtrl from '../controllers/room.controller.js';
|
|||||||
import {
|
import {
|
||||||
allowAnonymous,
|
allowAnonymous,
|
||||||
apiKeyValidator,
|
apiKeyValidator,
|
||||||
checkParticipantFromSameRoom,
|
|
||||||
configureRecordingTokenAuth,
|
configureRecordingTokenAuth,
|
||||||
configureRoomAuthorization,
|
configureRoomAuthorization,
|
||||||
participantTokenValidator,
|
participantTokenValidator,
|
||||||
@ -50,32 +49,32 @@ roomRouter.get(
|
|||||||
configureRoomAuthorization,
|
configureRoomAuthorization,
|
||||||
roomCtrl.getRoom
|
roomCtrl.getRoom
|
||||||
);
|
);
|
||||||
roomRouter.put(
|
|
||||||
'/:roomId',
|
|
||||||
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
|
|
||||||
withValidRoomId,
|
|
||||||
withValidRoomPreferences,
|
|
||||||
roomCtrl.updateRoomPreferences
|
|
||||||
);
|
|
||||||
roomRouter.delete(
|
roomRouter.delete(
|
||||||
'/:roomId',
|
'/:roomId',
|
||||||
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
|
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
|
||||||
withValidRoomDeleteRequest,
|
withValidRoomDeleteRequest,
|
||||||
roomCtrl.deleteRoom
|
roomCtrl.deleteRoom
|
||||||
);
|
);
|
||||||
|
roomRouter.get(
|
||||||
|
'/:roomId/preferences',
|
||||||
|
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN), participantTokenValidator),
|
||||||
|
withValidRoomId,
|
||||||
|
configureRoomAuthorization,
|
||||||
|
roomCtrl.getRoomPreferences
|
||||||
|
);
|
||||||
|
roomRouter.put(
|
||||||
|
'/:roomId/preferences',
|
||||||
|
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
|
||||||
|
withValidRoomId,
|
||||||
|
withValidRoomPreferences,
|
||||||
|
roomCtrl.updateRoomPreferences
|
||||||
|
);
|
||||||
|
|
||||||
// Internal room routes
|
// Internal room routes
|
||||||
export const internalRoomRouter = Router();
|
export const internalRoomRouter = Router();
|
||||||
internalRoomRouter.use(bodyParser.urlencoded({ extended: true }));
|
internalRoomRouter.use(bodyParser.urlencoded({ extended: true }));
|
||||||
internalRoomRouter.use(bodyParser.json());
|
internalRoomRouter.use(bodyParser.json());
|
||||||
|
|
||||||
internalRoomRouter.get(
|
|
||||||
'/:roomId/preferences',
|
|
||||||
withAuth(participantTokenValidator),
|
|
||||||
withValidRoomId,
|
|
||||||
checkParticipantFromSameRoom,
|
|
||||||
roomCtrl.getRoomPreferences
|
|
||||||
);
|
|
||||||
internalRoomRouter.post(
|
internalRoomRouter.post(
|
||||||
'/:roomId/recording-token',
|
'/:roomId/recording-token',
|
||||||
configureRecordingTokenAuth,
|
configureRecordingTokenAuth,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user