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

refactor service/activity.ts for using preNotify

WNomunomu 2 лет назад
Родитель
Сommit
b814b83801
1 измененных файлов с 8 добавлено и 4 удалено
  1. 8 4
      apps/app/src/server/service/activity.ts

+ 8 - 4
apps/app/src/server/service/activity.ts

@@ -5,12 +5,14 @@ import {
   IActivity, SupportedActionType, AllSupportedActions, ActionGroupSize,
   IActivity, SupportedActionType, AllSupportedActions, ActionGroupSize,
   AllEssentialActions, AllSmallGroupActions, AllMediumGroupActions, AllLargeGroupActions,
   AllEssentialActions, AllSmallGroupActions, AllMediumGroupActions, AllLargeGroupActions,
 } from '~/interfaces/activity';
 } from '~/interfaces/activity';
-import Activity from '~/server/models/activity';
+import Activity, { ActivityDocument } from '~/server/models/activity';
 
 
 import loggerFactory from '../../utils/logger';
 import loggerFactory from '../../utils/logger';
 import Crowi from '../crowi';
 import Crowi from '../crowi';
 
 
 
 
+import type { PreNotify } from './preNotify';
+
 const logger = loggerFactory('growi:service:ActivityService');
 const logger = loggerFactory('growi:service:ActivityService');
 
 
 const parseActionString = (actionsString: string): SupportedActionType[] => {
 const parseActionString = (actionsString: string): SupportedActionType[] => {
@@ -39,8 +41,8 @@ class ActivityService {
   }
   }
 
 
   initActivityEventListeners(): void {
   initActivityEventListeners(): void {
-    this.activityEvent.on('update', async(activityId: string, parameters, target?: IPage, descendantsSubscribedUsers?: Ref<IUser>[]) => {
-      let activity: IActivity;
+    this.activityEvent.on('update', async(activityId: string, parameters, target: IPage, getPreNotify: (activity: ActivityDocument) => PreNotify) => {
+      let activity: ActivityDocument;
       const shoudUpdate = this.shoudUpdateActivity(parameters.action);
       const shoudUpdate = this.shoudUpdateActivity(parameters.action);
 
 
       if (shoudUpdate) {
       if (shoudUpdate) {
@@ -52,7 +54,9 @@ class ActivityService {
           return;
           return;
         }
         }
 
 
-        this.activityEvent.emit('updated', activity, target, descendantsSubscribedUsers);
+        const preNotify = getPreNotify(activity);
+
+        this.activityEvent.emit('updated', activity, target, preNotify);
       }
       }
     });
     });
   }
   }