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

Exclude actions not included in AllSupportedAction

Shun Miyazawa 3 лет назад
Родитель
Сommit
02221d7ec9
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      packages/app/src/server/service/activity.ts

+ 5 - 2
packages/app/src/server/service/activity.ts

@@ -1,7 +1,8 @@
 import mongoose from 'mongoose';
 
 import {
-  IActivity, SupportedActionType, ActionGroupSize, AllSmallGroupActions, AllMediumGroupActions, AllLargeGroupActions, AllSupportedActionToNotified,
+  IActivity, SupportedActionType, ActionGroupSize, AllSupportedAction,
+  AllSmallGroupActions, AllMediumGroupActions, AllLargeGroupActions, AllSupportedActionToNotified,
 } from '~/interfaces/activity';
 import { IPage } from '~/interfaces/page';
 import Activity from '~/server/models/activity';
@@ -17,7 +18,8 @@ const parseActionString = (actionsString: string): SupportedActionType[] => {
     return [];
   }
 
-  return (actionsString as string).split(',').map(value => value.trim()) as SupportedActionType[];
+  const actions = (actionsString as string).split(',').map(value => value.trim()) as SupportedActionType[];
+  return actions.filter(action => AllSupportedAction.includes(action));
 };
 
 class ActivityService {
@@ -89,6 +91,7 @@ class ActivityService {
   }
 
   shoudUpdateActivity = function(action: SupportedActionType): boolean {
+    console.log(this.getAvailableActions());
     return this.getAvailableActions().includes(action);
   }