Explorar o código

add null handling

Shun Miyazawa %!s(int64=4) %!d(string=hai) anos
pai
achega
23c565c257
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      packages/app/src/server/service/comment.ts

+ 5 - 0
packages/app/src/server/service/comment.ts

@@ -34,7 +34,12 @@ class CommentService {
       try {
       try {
         const Page = getModelSafely('Page') || require('../models/page')(this.crowi);
         const Page = getModelSafely('Page') || require('../models/page')(this.crowi);
         await Page.updateCommentCount(savedComment.page);
         await Page.updateCommentCount(savedComment.page);
+
         const page = await Page.findById(savedComment.page);
         const page = await Page.findById(savedComment.page);
+        if (page == null) {
+          logger.error('Page is not found');
+          return;
+        }
 
 
         const activity = await this.createActivity(savedComment, ActivityDefine.ACTION_COMMENT_CREATE);
         const activity = await this.createActivity(savedComment, ActivityDefine.ACTION_COMMENT_CREATE);
         await this.createAndSendNotifications(activity, page);
         await this.createAndSendNotifications(activity, page);