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