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

"UNSETTLED" if action is not fixed

Shun Miyazawa 3 лет назад
Родитель
Сommit
b7756c0ff1

+ 4 - 1
packages/app/src/interfaces/activity.ts

@@ -5,6 +5,8 @@ import { IUser } from './user';
 const MODEL_PAGE = 'Page';
 const MODEL_PAGE = 'Page';
 
 
 // Action
 // Action
+const ACTION_UNSETTLED = 'UNSETTLED';
+
 const ACTION_PAGE_LIKE = 'PAGE_LIKE';
 const ACTION_PAGE_LIKE = 'PAGE_LIKE';
 const ACTION_PAGE_BOOKMARK = 'PAGE_BOOKMARK';
 const ACTION_PAGE_BOOKMARK = 'PAGE_BOOKMARK';
 const ACTION_PAGE_CREATE = 'PAGE_CREATE';
 const ACTION_PAGE_CREATE = 'PAGE_CREATE';
@@ -23,6 +25,7 @@ export const SUPPORTED_TARGET_MODEL_TYPE = {
 } as const;
 } as const;
 
 
 export const SUPPORTED_ACTION_TYPE = {
 export const SUPPORTED_ACTION_TYPE = {
+  ACTION_UNSETTLED,
   ACTION_PAGE_LIKE,
   ACTION_PAGE_LIKE,
   ACTION_PAGE_BOOKMARK,
   ACTION_PAGE_BOOKMARK,
   ACTION_PAGE_CREATE,
   ACTION_PAGE_CREATE,
@@ -74,7 +77,7 @@ export type IActivity = {
   path: string
   path: string
   targetModel?: SupportedTargetModelType
   targetModel?: SupportedTargetModelType
   target?: string
   target?: string
-  action?: SupportedActionType
+  action: SupportedActionType
   createdAt: Date
   createdAt: Date
   snapshot?: ISnapshot
   snapshot?: ISnapshot
 }
 }

+ 2 - 0
packages/app/src/server/middlewares/add-activity.ts

@@ -1,5 +1,6 @@
 import { NextFunction, Request, Response } from 'express';
 import { NextFunction, Request, Response } from 'express';
 
 
+import { SUPPORTED_ACTION_TYPE } from '~/interfaces/activity';
 import { IUserHasId } from '~/interfaces/user';
 import { IUserHasId } from '~/interfaces/user';
 import loggerFactory from '~/utils/logger';
 import loggerFactory from '~/utils/logger';
 
 
@@ -19,6 +20,7 @@ export const generateAddActivityMiddleware = crowi => async(req: AuthorizedReque
   const parameter = {
   const parameter = {
     ip,
     ip,
     path,
     path,
+    action: SUPPORTED_ACTION_TYPE.ACTION_UNSETTLED,
     user: user?._id,
     user: user?._id,
     snapshot: {
     snapshot: {
       username: user?.username,
       username: user?.username,

+ 1 - 0
packages/app/src/server/models/activity.ts

@@ -61,6 +61,7 @@ const activitySchema = new Schema<ActivityDocument, ActivityModel>({
   action: {
   action: {
     type: String,
     type: String,
     enum: AllSupportedActionType,
     enum: AllSupportedActionType,
+    required: true,
   },
   },
   snapshot: snapshotSchema,
   snapshot: snapshotSchema,
 }, {
 }, {