From a25ef242379c4c43092a3a0d7f9d9e8c0e011bce Mon Sep 17 00:00:00 2001 From: John Livingston Date: Fri, 30 Apr 2021 18:03:12 +0200 Subject: [PATCH] WIP. --- server/lib/routers/api.ts | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/server/lib/routers/api.ts b/server/lib/routers/api.ts index 4a4782ed..6393e4c3 100644 --- a/server/lib/routers/api.ts +++ b/server/lib/routers/api.ts @@ -23,17 +23,28 @@ async function initApiRouter (options: RegisterServerOptions): Promise { const router = getRouter() const logger = peertubeHelpers.logger - router.get('/room', async (req: Request, res: Response, _next: NextFunction) => { - const jid: string = req.query.jid as string || '' - logger.info(`Requesting room information for room '${jid}'.`) - // TODO: check if room is legit and fill informations - const roomDefaults: RoomDefaults = { - name: 'name_of_the_room', - description: 'room description', - public: false, - subject: 'subject' + router.get('/room', async (req: Request, res: Response, next: NextFunction) => { + try { + const jid: string = req.query.jid as string || '' + logger.info(`Requesting room information for room '${jid}'.`) + + const video = await peertubeHelpers.videos.loadByIdOrUUID(jid) + if (!video) { + throw new Error('Video not found') + } + // FIXME: check settings (chat enabled for this video) + + // TODO: check if room is legit and fill informations + const roomDefaults: RoomDefaults = { + name: video.name, + description: '', + public: false, + subject: video.name + } + res.json(roomDefaults) + } catch (error) { + next(error) } - res.json(roomDefaults) }) return router