Skip to content

Commit

Permalink
Merge branch 'release/v1.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
HYOSITIVE committed Oct 23, 2023
2 parents 57e448e + 1aa2bff commit ee4ab34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 9 additions & 0 deletions functions/api/routes/category/categoryDELETE.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ module.exports = asyncWrapper(async (req, res) => {

const dbConnection = await db.connect(req);
req.dbConnection = dbConnection;

const category = await categoryDB.getCategory(dbConnection, categoryId);
if (!category) {
return res.status(statusCode.NOT_FOUND).send(util.fail(statusCode.NOT_FOUND, responseMessage.NO_CATEGORY));
}
if (category.userId !== userId) {
return res.status(statusCode.FORBIDDEN).send(util.fail(statusCode.FORBIDDEN, responseMessage.FORBIDDEN));
}

await Promise.all([
categoryDB.deleteCategory(dbConnection, categoryId, userId), // 해당 카테고리 soft delete
contentDB.updateContentIsDeleted(dbConnection, categoryId, userId), // 카테고리 개수가 1개 (해당 카테고리뿐)인 콘텐츠 soft delete
Expand Down
9 changes: 4 additions & 5 deletions functions/api/routes/content/contentDELETE.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ module.exports = asyncWrapper(async (req, res) => {
dayjs.tz.setDefault('Asia/Seoul');

const content = await contentDB.getContentById(dbConnection, contentId);
if (!content) {
return res.status(statusCode.NOT_FOUND).send(util.fail(statusCode.NOT_FOUND, responseMessage.NO_CONTENT));
}
if (content.userId !== userId) {
return res.status(statusCode.FORBIDDEN).send(util.fail(statusCode.FORBIDDEN, responseMessage.FORBIDDEN));
}

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

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

0 comments on commit ee4ab34

Please sign in to comment.