From 37428ccf1d1c26d03f59b75f5f2fb604ea5ae35c Mon Sep 17 00:00:00 2001 From: youngkwon02 Date: Fri, 14 Jan 2022 15:55:10 +0900 Subject: [PATCH 1/3] style: GET_WAITROOM_DATA_FULL res message --- functions/constants/responseMessage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/constants/responseMessage.js b/functions/constants/responseMessage.js index 141d8c1..bd53cbb 100644 --- a/functions/constants/responseMessage.js +++ b/functions/constants/responseMessage.js @@ -29,6 +29,7 @@ module.exports = { GET_WAITROOM_DATA_ALREADY: '이미 사용자가 참가중인 방입니다', GET_WAITROOM_DATA_FAIL: '대기방 정보 확인 실패', GET_WAITROOM_DATA_KICKED: '습관 방 생성자에 의해 내보내진 방입니다', + GET_WAITROOM_DATA_FULL: '정원이 가득찬 습관방입니다', ENTER_ROOM_SUCCESS: '습관 방 참여 완료', ENTER_ROOM_FAIL: '습관 방 참여 실패', ENTER_ROOM_ALREADY: '이미 참여중인 습관 방입니다', From 755b96b19bfbb8535702fd504fcb7865486d3091 Mon Sep 17 00:00:00 2001 From: youngkwon02 Date: Fri, 14 Jan 2022 15:55:51 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EC=BD=94=EB=93=9C=EB=A1=9C=20?= =?UTF-8?q?=EB=8C=80=EA=B8=B0=EB=B0=A9=20=EC=A1=B0=ED=9A=8C=EC=8B=9C=20?= =?UTF-8?q?=EC=A0=95=EC=9B=90=20=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/room/roomCodeGET.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/functions/api/routes/room/roomCodeGET.js b/functions/api/routes/room/roomCodeGET.js index 36af144..acdfd89 100644 --- a/functions/api/routes/room/roomCodeGET.js +++ b/functions/api/routes/room/roomCodeGET.js @@ -14,6 +14,7 @@ const { userDB, roomDB } = require('../../../db'); * 3. 이미 시작된 습관방인 경우 * 4. 이미 참여중인 방인 경우 * 5. 한번 내보내진 사용자인 경우 + * 6. 정원이 가득찬 습관방 */ module.exports = async (req, res) => { @@ -66,6 +67,11 @@ module.exports = async (req, res) => { } } + // @error 6. 정원이 가득찬 습관방 + if (entries.length > 9) { + return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.GET_WAITROOM_DATA_FULL)); + } + const data = { roomId: room.roomId, roomName: room.roomName, From e17c66f7d1a03caf1a292f130429ca375b02ff9a Mon Sep 17 00:00:00 2001 From: youngkwon02 Date: Fri, 14 Jan 2022 16:01:20 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=EB=8C=80=EA=B8=B0=EB=B0=A9=20?= =?UTF-8?q?=EC=9E=85=EC=9E=A5=EC=8B=9C=20=EC=A0=95=EC=9B=90=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/room/roomEnterPOST.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/functions/api/routes/room/roomEnterPOST.js b/functions/api/routes/room/roomEnterPOST.js index bb20a11..7adf953 100644 --- a/functions/api/routes/room/roomEnterPOST.js +++ b/functions/api/routes/room/roomEnterPOST.js @@ -12,7 +12,8 @@ const { roomDB } = require('../../../db'); * @error * 1. roomId가 올바르지 않음 (이미 삭제된 방이거나 존재하지 않은 방) * 2. 사용자가 이미 참여중인 방임 - * 3. 습관방 참여 실패 + * 3. 정원이 가득찬 습관방 + * 4. 습관방 참여 실패 */ module.exports = async (req, res) => { @@ -38,8 +39,15 @@ module.exports = async (req, res) => { return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.ENTER_ROOM_ALREADY)); } + // error 3. 정원이 가득찬 습관방 + const entries = roomDB.getEntriesByRoomId(client, roomId); + if (entries.length > 9) { + return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.GET_WAITROOM_DATA_FULL)); + } + const enterEntry = await roomDB.enterById(client, roomId, userId); - // @error 3. 습관 방 참여 실패 + + // @error 4. 습관 방 참여 실패 if (!enterEntry) { return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.ENTER_ROOM_FAIL)); }