Skip to content

Commit ee4ab34

Browse files
committed
Merge branch 'release/v1.0.6'
2 parents 57e448e + 1aa2bff commit ee4ab34

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

functions/api/routes/category/categoryDELETE.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ module.exports = asyncWrapper(async (req, res) => {
1717

1818
const dbConnection = await db.connect(req);
1919
req.dbConnection = dbConnection;
20+
21+
const category = await categoryDB.getCategory(dbConnection, categoryId);
22+
if (!category) {
23+
return res.status(statusCode.NOT_FOUND).send(util.fail(statusCode.NOT_FOUND, responseMessage.NO_CATEGORY));
24+
}
25+
if (category.userId !== userId) {
26+
return res.status(statusCode.FORBIDDEN).send(util.fail(statusCode.FORBIDDEN, responseMessage.FORBIDDEN));
27+
}
28+
2029
await Promise.all([
2130
categoryDB.deleteCategory(dbConnection, categoryId, userId), // 해당 카테고리 soft delete
2231
contentDB.updateContentIsDeleted(dbConnection, categoryId, userId), // 카테고리 개수가 1개 (해당 카테고리뿐)인 콘텐츠 soft delete

functions/api/routes/content/contentDELETE.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ module.exports = asyncWrapper(async (req, res) => {
3535
dayjs.tz.setDefault('Asia/Seoul');
3636

3737
const content = await contentDB.getContentById(dbConnection, contentId);
38+
if (!content) {
39+
return res.status(statusCode.NOT_FOUND).send(util.fail(statusCode.NOT_FOUND, responseMessage.NO_CONTENT));
40+
}
3841
if (content.userId !== userId) {
3942
return res.status(statusCode.FORBIDDEN).send(util.fail(statusCode.FORBIDDEN, responseMessage.FORBIDDEN));
4043
}
4144

42-
const deletedContent = await contentDB.deleteContent(dbConnection, contentId, userId);
43-
if (!deletedContent) {
44-
// 대상 콘텐츠가 없는 경우, 콘텐츠 삭제 실패
45-
return res.status(statusCode.NOT_FOUND).send(util.fail(statusCode.NOT_FOUND, responseMessage.NO_CONTENT));
46-
}
45+
await contentDB.deleteContent(dbConnection, contentId, userId);
4746

4847
if (content.isNotified && content.notificationTime > dayjs().tz().$d) {
4948
// 알림 예정 일 때 푸시서버에서도 삭제

0 commit comments

Comments
 (0)