itizawa 6 лет назад
Родитель
Сommit
261df56ae6
1 измененных файлов с 14 добавлено и 16 удалено
  1. 14 16
      src/server/routes/comment.js

+ 14 - 16
src/server/routes/comment.js

@@ -176,26 +176,24 @@ module.exports = function(crowi, app) {
       return res.json(ApiResponse.error('Current user is not accessible to this page.'));
     }
 
-    const updatedComment = await Comment.updateCommentsByPageId(comment, isMarkdown, commentId)
-      .catch((err) => {
-        return res.json(ApiResponse.error(err));
-      });
-
-    // update page
-    const page = await Page.findOneAndUpdate({ _id: pageId }, {
-      lastUpdateUser: req.user,
-      updatedAt: new Date(),
-    }).catch((err) => {
-      return res.json(ApiResponse.error(err));
-    });
+    try {
+      const updatedComment = await Comment.updateCommentsByPageId(comment, isMarkdown, commentId);
 
-    res.json(ApiResponse.success({ comment: updatedComment }));
+      const page = await Page.findOneAndUpdate({ _id: pageId }, {
+        lastUpdateUser: req.user,
+        updatedAt: new Date(),
+      });
 
-    const path = page.path;
+      res.json(ApiResponse.success({ comment: updatedComment }));
 
-    // global notification
-    globalNotificationService.notifyComment(updatedComment, path);
+      const path = page.path;
 
+      // global notification
+      globalNotificationService.notifyComment(updatedComment, path);
+    }
+    catch (err) {
+      return res.json(ApiResponse.error(err));
+    }
   };