Prechádzať zdrojové kódy

modified the activity code based off the 1st FB

Shunm634-source 3 rokov pred
rodič
commit
b8d0d22bb7

+ 6 - 0
packages/app/src/server/routes/comment.js

@@ -1,3 +1,4 @@
+import { SUPPORTED_ACTION_TYPE } from '~/interfaces/activity';
 import loggerFactory from '~/utils/logger';
 
 /**
@@ -53,6 +54,8 @@ module.exports = function(crowi, app) {
   const GlobalNotificationSetting = crowi.model('GlobalNotificationSetting');
   const ApiResponse = require('../util/apiResponse');
 
+  const activityEvent = crowi.event('activity');
+
   const globalNotificationService = crowi.getGlobalNotificationService();
   const userNotificationService = crowi.getUserNotificationService();
 
@@ -465,6 +468,9 @@ module.exports = function(crowi, app) {
       return res.json(ApiResponse.error(err));
     }
 
+    const parameters = { action: SUPPORTED_ACTION_TYPE.ACTION_COMMENT_REMOVE };
+    activityEvent.emit('update', res.locals.activity._id, parameters);
+
     return res.json(ApiResponse.success({}));
   };
 

+ 1 - 8
packages/app/src/server/service/comment.ts

@@ -72,7 +72,7 @@ class CommentService {
     });
 
     // remove
-    this.commentEvent.on('delete', async(user, removedComment) => {
+    this.commentEvent.on('delete', async(removedComment) => {
       this.commentEvent.onDelete();
 
       try {
@@ -82,13 +82,6 @@ class CommentService {
       catch (err) {
         logger.error('Error occurred while updating the comment count:\n', err);
       }
-
-      try {
-        await this.createActivity(user, removedComment.page, SUPPORTED_ACTION_TYPE.ACTION_COMMENT_REMOVE);
-      }
-      catch (err) {
-        logger.error('Error occurred while handling the comment removal event:\n', err);
-      }
     });
   }