Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] 고민중 2회 이상 불가능하게 처리 #192

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion functions/api/routes/room/roomStatusPOST.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const { userDB, roomDB, recordDB, noticeDB } = require('../../../db');
* 4. 습관 시작하지 않은 방에서의 요청
* 5. 이미 인증을 완료한 사용자로부터의 요청
* 6. 이미 쉴래요를 사용한 사용자로부터의 요청
* 7. 쉴래요 잔여횟수가 0인 사용쟈로부터의 요청
* 8. 이미 고민중 상태의 사용자로부터의 요청
*/

module.exports = async (req, res) => {
Expand Down Expand Up @@ -69,7 +71,7 @@ module.exports = async (req, res) => {
}

if (statusType === 'REST') {
// @error 7. 쉴래요 가능 횟수가 0인 사용쟈
// @error 7. 쉴래요 잔여횟수가 0인 사용쟈로부터의 요청
const rawRest = await roomDB.getRestCountByIds(client, roomId, userId);
const restCount = rawRest.rest;
if (restCount < 1) {
Expand All @@ -84,6 +86,10 @@ module.exports = async (req, res) => {

// 고민중을 눌렀으면 Notification에 추가, PushAlarm 전송
if (statusType === 'CONSIDER') {
// @error 8. 이미 고민중 상태의 사용자로부터의 요청
if (recentRecord.status === 'CONSIDER') {
return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.CONSIDER_ALREADY_DONE));
}
const sender = await userDB.getUserById(client, userId);
const receivers = await roomDB.getFriendsByIds(client, roomId, userId);
const receiversIds = receivers.map((r) => r.userId);
Expand Down
1 change: 1 addition & 0 deletions functions/constants/responseMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ module.exports = {
INVALID_USER_STATUS: '유효하지 않은 status type입니다',
CERTIFICATION_ALREADY_DONE: '이미 인증을 완료하였습니다',
REST_ALREADY_DONE: '이미 쉴래요를 사용한 사용자입니다',
CONSIDER_ALREADY_DONE: '이미 고민중 상태의 사용자입니다',
UPDATE_STATUS_SUCCESS: '상태 변경 완료',
REST_COUNT_ZERO: '쉴래요 사용 가능 횟수가 0인 사용자입니다',

Expand Down