Просмотр исходного кода

get comment by comment ID

https://youtrack.weseek.co.jp/issue/GW-7812
- Add method to get comment by comment Id
-  Implement getMentionedUsers method
I Komang Mudana 3 лет назад
Родитель
Сommit
2261f24997

+ 3 - 0
packages/app/src/server/models/comment.js

@@ -94,6 +94,9 @@ module.exports = function(crowi) {
     return commentData;
   };
 
+  commentSchema.statics.findCommentById = async function(commentId) {
+    return this.findOne({ commentId });
+  };
 
   /**
    * post remove hook

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

@@ -107,11 +107,10 @@ class CommentService {
     await this.inAppNotificationService.emitSocketIo(targetUsers);
   };
 
-  private getMentionedUsers = async(comment: Types.ObjectId) => {
-    // TODO extract users from comment model
-    // Implement User model to find users ID
-
-    // return User ObjectID array
+  getMentionedUsers = async(commentId: Types.ObjectId) => {
+    const Comment = getModelSafely('Comment') || require('../models/comment')(this.crowi);
+    const comment = await Comment.findCommentById(commentId);
+    // TODO  get users from comment
   }
 
 }