Browse Source

fix GW-213: unhandled rejection occured when updating comments

Yuki Takei 6 năm trước cách đây
mục cha
commit
92f735921d
1 tập tin đã thay đổi với 7 bổ sung13 xóa
  1. 7 13
      src/server/routes/comment.js

+ 7 - 13
src/server/routes/comment.js

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