Skip to content

Commit e875777

Browse files
authored
Merge pull request #254 from boostcampwm-2024/feature-be-live_replay_checker_api
[FEAT] 방송/다시보기 존재 여부에 대한 체크 api
2 parents d24e4af + 86e9327 commit e875777

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

backend/mainServer/src/replay/replay.controller.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,20 @@ export class ReplayController {
5858
}
5959
}
6060

61+
@Get('/existence')
62+
@ApiOperation({summary: 'Get replay exited', description: '다시보기에 대한 존재 여부를 반환 받습니다.'})
63+
async getExistence(@Query('videoId') videoId: string, @Res() res: Response) {
64+
try {
65+
const replaySessions = this.memoryDBService.findAll().filter((info) => info.replay);
66+
if (replaySessions.some((info) => info.sessionKey === videoId)) {
67+
res.status(HttpStatus.OK).json({exited: true});
68+
}
69+
else {
70+
res.status(HttpStatus.OK).json({exited: false});
71+
}
72+
} catch (err) {
73+
console.log(err);
74+
res.status(HttpStatus.INTERNAL_SERVER_ERROR).send();
75+
}
76+
}
6177
}

backend/mainServer/src/streams/streams.controller.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,21 @@ export class StreamsController {
9999
}
100100
}
101101
}
102+
103+
@Get('/existence')
104+
@ApiOperation({summary: 'Get Session exited', description: '방송 세션에 대한 존재 여부를 반환 받습니다.'})
105+
async getExistence(@Query('sessionKey') sessionKey: string, @Res() res: Response) {
106+
try {
107+
const liveSessions = this.memoryDBService.findAll().filter((info) => info.state);
108+
if (liveSessions.some((info) => info.sessionKey === sessionKey)) {
109+
res.status(HttpStatus.OK).json({exited: true});
110+
}
111+
else {
112+
res.status(HttpStatus.OK).json({exited: false});
113+
}
114+
} catch (err) {
115+
console.log(err);
116+
res.status(HttpStatus.INTERNAL_SERVER_ERROR).send();
117+
}
118+
}
102119
}

0 commit comments

Comments
 (0)