2
0
Эх сурвалжийг харах

create "getAvailableActions"

Shun Miyazawa 3 жил өмнө
parent
commit
bd40cdead7

+ 12 - 8
packages/app/src/server/service/activity.ts

@@ -22,6 +22,7 @@ class ActivityService {
     this.crowi = crowi;
     this.crowi = crowi;
     this.activityEvent = crowi.event('activity');
     this.activityEvent = crowi.event('activity');
 
 
+    this.getAvailableActions = this.getAvailableActions.bind(this);
     this.shoudUpdateActivity = this.shoudUpdateActivity.bind(this);
     this.shoudUpdateActivity = this.shoudUpdateActivity.bind(this);
 
 
     this.initActivityEventListeners();
     this.initActivityEventListeners();
@@ -46,25 +47,28 @@ class ActivityService {
     });
     });
   }
   }
 
 
-  shoudUpdateActivity = function(action: SupportedActionType): boolean {
-    const configManager = this.crowi.configManager;
-    const auditLogActionGroupSize = configManager != null ? configManager.getConfig('crowi', 'app:auditLogActionGroupSize') : ActionGroupSize.Small;
+  getAvailableActions = function(): SupportedActionType[] {
+    const auditLogActionGroupSize = this.crowi.configManager.getConfig('crowi', 'app:auditLogActionGroupSize') || ActionGroupSize.Small;
 
 
-    let shoudUpdate = false;
+    const availableActions: SupportedActionType[] = [...AllSupportedActionToNotified];
 
 
     switch (auditLogActionGroupSize) {
     switch (auditLogActionGroupSize) {
       case ActionGroupSize.Small:
       case ActionGroupSize.Small:
-        shoudUpdate = (AllSmallGroupActions as ReadonlyArray<string>).includes(action);
+        availableActions.push(...AllSmallGroupActions);
         break;
         break;
       case ActionGroupSize.Medium:
       case ActionGroupSize.Medium:
-        shoudUpdate = (AllMediumGroupActions as ReadonlyArray<string>).includes(action);
+        availableActions.push(...AllMediumGroupActions);
         break;
         break;
       case ActionGroupSize.Large:
       case ActionGroupSize.Large:
-        shoudUpdate = (AllLargeGroupActions as ReadonlyArray<string>).includes(action);
+        availableActions.push(...AllLargeGroupActions);
         break;
         break;
     }
     }
 
 
-    return shoudUpdate || (AllSupportedActionToNotified as ReadonlyArray<string>).includes(action);
+    return Array.from(new Set(availableActions));
+  }
+
+  shoudUpdateActivity = function(action: SupportedActionType): boolean {
+    return this.getAvailableActions().includes(action);
   }
   }
 
 
   createTtlIndex = async function() {
   createTtlIndex = async function() {