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

AllSupportedActionToNotified -> AllEssentialActions

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

+ 14 - 13
packages/app/src/interfaces/activity.ts

@@ -110,6 +110,19 @@ export const SupportedAction = {
   ACTION_ADMIN_SEARCH_INDICES_REBUILD,
   ACTION_ADMIN_SEARCH_INDICES_REBUILD,
 } as const;
 } as const;
 
 
+// Action required for notification
+export const EssentialActionGroup = {
+  ACTION_PAGE_LIKE,
+  ACTION_PAGE_BOOKMARK,
+  ACTION_PAGE_UPDATE,
+  ACTION_PAGE_RENAME,
+  ACTION_PAGE_DUPLICATE,
+  ACTION_PAGE_DELETE,
+  ACTION_PAGE_DELETE_COMPLETELY,
+  ACTION_PAGE_REVERT,
+  ACTION_COMMENT_CREATE,
+} as const;
+
 export const ActionGroupSize = {
 export const ActionGroupSize = {
   Small: 'SMALL',
   Small: 'SMALL',
   Medium: 'MEDIUM',
   Medium: 'MEDIUM',
@@ -173,18 +186,6 @@ export const LargeActionGroup = {
   ACTION_ADMIN_SEARCH_INDICES_REBUILD,
   ACTION_ADMIN_SEARCH_INDICES_REBUILD,
 } as const;
 } as const;
 
 
-export const SupportedActionToNotified = {
-  ACTION_PAGE_LIKE,
-  ACTION_PAGE_BOOKMARK,
-  ACTION_PAGE_UPDATE,
-  ACTION_PAGE_RENAME,
-  ACTION_PAGE_DUPLICATE,
-  ACTION_PAGE_DELETE,
-  ACTION_PAGE_DELETE_COMPLETELY,
-  ACTION_PAGE_REVERT,
-  ACTION_COMMENT_CREATE,
-} as const;
-
 /*
 /*
  * For AuditLogManagement.tsx
  * For AuditLogManagement.tsx
  */
  */
@@ -211,7 +212,7 @@ export const CommentActions = Object.values({
 export const AllSupportedTargetModels = Object.values(SupportedTargetModel);
 export const AllSupportedTargetModels = Object.values(SupportedTargetModel);
 export const AllSupportedEventModels = Object.values(SupportedEventModel);
 export const AllSupportedEventModels = Object.values(SupportedEventModel);
 export const AllSupportedActions = Object.values(SupportedAction);
 export const AllSupportedActions = Object.values(SupportedAction);
-export const AllSupportedActionToNotified = Object.values(SupportedActionToNotified);
+export const AllEssentialActions = Object.values(EssentialActionGroup);
 export const AllSmallGroupActions = Object.values(SmallActionGroup);
 export const AllSmallGroupActions = Object.values(SmallActionGroup);
 export const AllMediumGroupActions = Object.values(MediumActionGroup);
 export const AllMediumGroupActions = Object.values(MediumActionGroup);
 export const AllLargeGroupActions = Object.values(LargeActionGroup);
 export const AllLargeGroupActions = Object.values(LargeActionGroup);

+ 3 - 3
packages/app/src/server/service/activity.ts

@@ -1,8 +1,8 @@
 import mongoose from 'mongoose';
 import mongoose from 'mongoose';
 
 
 import {
 import {
-  IActivity, SupportedActionType, ActionGroupSize, AllSupportedActions,
-  AllSmallGroupActions, AllMediumGroupActions, AllLargeGroupActions, AllSupportedActionToNotified,
+  IActivity, SupportedActionType, AllSupportedActions, ActionGroupSize,
+  AllEssentialActions, AllSmallGroupActions, AllMediumGroupActions, AllLargeGroupActions,
 } from '~/interfaces/activity';
 } from '~/interfaces/activity';
 import { IPage } from '~/interfaces/page';
 import { IPage } from '~/interfaces/page';
 import Activity from '~/server/models/activity';
 import Activity from '~/server/models/activity';
@@ -87,7 +87,7 @@ class ActivityService {
 
 
     // Add essentialActions
     // Add essentialActions
     if (isIncludeEssentialActions) {
     if (isIncludeEssentialActions) {
-      AllSupportedActionToNotified.forEach(action => availableActionsSet.add(action));
+      AllEssentialActions.forEach(action => availableActionsSet.add(action));
     }
     }
 
 
     return Array.from(availableActionsSet);
     return Array.from(availableActionsSet);

+ 3 - 3
packages/app/src/server/service/in-app-notification.ts

@@ -1,7 +1,7 @@
 import { subDays } from 'date-fns';
 import { subDays } from 'date-fns';
 import { Types } from 'mongoose';
 import { Types } from 'mongoose';
 
 
-import { AllSupportedActionToNotified, SupportedAction } from '~/interfaces/activity';
+import { AllEssentialActions, SupportedAction } from '~/interfaces/activity';
 import { HasObjectId } from '~/interfaces/has-object-id';
 import { HasObjectId } from '~/interfaces/has-object-id';
 import { InAppNotificationStatuses, PaginateResult } from '~/interfaces/in-app-notification';
 import { InAppNotificationStatuses, PaginateResult } from '~/interfaces/in-app-notification';
 import { IPage } from '~/interfaces/page';
 import { IPage } from '~/interfaces/page';
@@ -53,7 +53,7 @@ export default class InAppNotificationService {
   initActivityEventListeners(): void {
   initActivityEventListeners(): void {
     this.activityEvent.on('updated', async(activity: ActivityDocument, target: IPage) => {
     this.activityEvent.on('updated', async(activity: ActivityDocument, target: IPage) => {
       try {
       try {
-        const shouldNotification = activity != null && target != null && (AllSupportedActionToNotified as ReadonlyArray<string>).includes(activity.action);
+        const shouldNotification = activity != null && target != null && (AllEssentialActions as ReadonlyArray<string>).includes(activity.action);
         if (shouldNotification) {
         if (shouldNotification) {
           await this.createInAppNotification(activity, target);
           await this.createInAppNotification(activity, target);
         }
         }
@@ -200,7 +200,7 @@ export default class InAppNotificationService {
   };
   };
 
 
   createInAppNotification = async function(activity: ActivityDocument, target: IPage): Promise<void> {
   createInAppNotification = async function(activity: ActivityDocument, target: IPage): Promise<void> {
-    const shouldNotification = activity != null && target != null && (AllSupportedActionToNotified as ReadonlyArray<string>).includes(activity.action);
+    const shouldNotification = activity != null && target != null && (AllEssentialActions as ReadonlyArray<string>).includes(activity.action);
     if (shouldNotification) {
     if (shouldNotification) {
       let mentionedUsers: IUser[] = [];
       let mentionedUsers: IUser[] = [];
       if (activity.action === SupportedAction.ACTION_COMMENT_CREATE) {
       if (activity.action === SupportedAction.ACTION_COMMENT_CREATE) {