From 86e9327b847b8370da5d2f5d9e909c80eeac51cb Mon Sep 17 00:00:00 2001 From: i3kae Date: Sat, 30 Nov 2024 21:28:16 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B0=A9=EC=86=A1/=EB=8B=A4=EC=8B=9C?= =?UTF-8?q?=EB=B3=B4=EA=B8=B0=20=EC=A1=B4=EC=9E=AC=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=B2=B4=ED=81=AC=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainServer/src/replay/replay.controller.ts | 16 ++++++++++++++++ .../src/streams/streams.controller.ts | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/backend/mainServer/src/replay/replay.controller.ts b/backend/mainServer/src/replay/replay.controller.ts index 76288cad..cf11f904 100644 --- a/backend/mainServer/src/replay/replay.controller.ts +++ b/backend/mainServer/src/replay/replay.controller.ts @@ -58,4 +58,20 @@ export class ReplayController { } } + @Get('/existence') + @ApiOperation({summary: 'Get replay exited', description: '다시보기에 대한 존재 여부를 반환 받습니다.'}) + async getExistence(@Query('videoId') videoId: string, @Res() res: Response) { + try { + const replaySessions = this.memoryDBService.findAll().filter((info) => info.replay); + if (replaySessions.some((info) => info.sessionKey === videoId)) { + res.status(HttpStatus.OK).json({exited: true}); + } + else { + res.status(HttpStatus.OK).json({exited: false}); + } + } catch (err) { + console.log(err); + res.status(HttpStatus.INTERNAL_SERVER_ERROR).send(); + } + } } diff --git a/backend/mainServer/src/streams/streams.controller.ts b/backend/mainServer/src/streams/streams.controller.ts index 2a84a162..eeb65f53 100644 --- a/backend/mainServer/src/streams/streams.controller.ts +++ b/backend/mainServer/src/streams/streams.controller.ts @@ -99,4 +99,21 @@ export class StreamsController { } } } + + @Get('/existence') + @ApiOperation({summary: 'Get Session exited', description: '방송 세션에 대한 존재 여부를 반환 받습니다.'}) + async getExistence(@Query('sessionKey') sessionKey: string, @Res() res: Response) { + try { + const liveSessions = this.memoryDBService.findAll().filter((info) => info.state); + if (liveSessions.some((info) => info.sessionKey === sessionKey)) { + res.status(HttpStatus.OK).json({exited: true}); + } + else { + res.status(HttpStatus.OK).json({exited: false}); + } + } catch (err) { + console.log(err); + res.status(HttpStatus.INTERNAL_SERVER_ERROR).send(); + } + } } \ No newline at end of file