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

Commonality of generatedefaultprenotify and generateprenotifyalsodescendants

WNomunomu 2 лет назад
Родитель
Сommit
efb66571ad

+ 2 - 2
apps/app/src/server/routes/apiv3/bookmarks.js

@@ -1,7 +1,7 @@
 import { SupportedAction, SupportedTargetModel } from '~/interfaces/activity';
 import { SupportedAction, SupportedTargetModel } from '~/interfaces/activity';
 import { generateAddActivityMiddleware } from '~/server/middlewares/add-activity';
 import { generateAddActivityMiddleware } from '~/server/middlewares/add-activity';
 import { serializeBookmarkSecurely } from '~/server/models/serializers/bookmark-serializer';
 import { serializeBookmarkSecurely } from '~/server/models/serializers/bookmark-serializer';
-import { generateDefaultPreNotify } from '~/server/service/preNotify';
+import { generatePreNotify } from '~/server/service/preNotify';
 import loggerFactory from '~/utils/logger';
 import loggerFactory from '~/utils/logger';
 
 
 import { apiV3FormValidator } from '../../middlewares/apiv3-form-validator';
 import { apiV3FormValidator } from '../../middlewares/apiv3-form-validator';
@@ -303,7 +303,7 @@ module.exports = (crowi) => {
       action: bool ? SupportedAction.ACTION_PAGE_BOOKMARK : SupportedAction.ACTION_PAGE_UNBOOKMARK,
       action: bool ? SupportedAction.ACTION_PAGE_BOOKMARK : SupportedAction.ACTION_PAGE_UNBOOKMARK,
     };
     };
 
 
-    activityEvent.emit('update', res.locals.activity._id, parameters, page, generateDefaultPreNotify);
+    activityEvent.emit('update', res.locals.activity._id, parameters, page, generatePreNotify);
 
 
     return res.apiv3({ bookmark });
     return res.apiv3({ bookmark });
   });
   });

+ 2 - 4
apps/app/src/server/routes/apiv3/page.js

@@ -14,10 +14,8 @@ import { apiV3FormValidator } from '~/server/middlewares/apiv3-form-validator';
 import { excludeReadOnlyUser } from '~/server/middlewares/exclude-read-only-user';
 import { excludeReadOnlyUser } from '~/server/middlewares/exclude-read-only-user';
 import Subscription from '~/server/models/subscription';
 import Subscription from '~/server/models/subscription';
 import UserGroup from '~/server/models/user-group';
 import UserGroup from '~/server/models/user-group';
-import { generateDefaultPreNotify } from '~/server/service/preNotify';
-
+import { generatePreNotify } from '~/server/service/preNotify';
 import { divideByType } from '~/server/util/granted-group';
 import { divideByType } from '~/server/util/granted-group';
-
 import loggerFactory from '~/utils/logger';
 import loggerFactory from '~/utils/logger';
 
 
 
 
@@ -366,7 +364,7 @@ module.exports = (crowi) => {
       action: isLiked ? SupportedAction.ACTION_PAGE_LIKE : SupportedAction.ACTION_PAGE_UNLIKE,
       action: isLiked ? SupportedAction.ACTION_PAGE_LIKE : SupportedAction.ACTION_PAGE_UNLIKE,
     };
     };
 
 
-    activityEvent.emit('update', res.locals.activity._id, parameters, page, generateDefaultPreNotify);
+    activityEvent.emit('update', res.locals.activity._id, parameters, page, generatePreNotify);
 
 
 
 
     res.apiv3({ result });
     res.apiv3({ result });

+ 2 - 2
apps/app/src/server/routes/apiv3/pages.js

@@ -6,7 +6,7 @@ import { normalizePath, addHeadingSlash, attachTitleHeader } from '@growi/core/d
 
 
 import { SupportedTargetModel, SupportedAction } from '~/interfaces/activity';
 import { SupportedTargetModel, SupportedAction } from '~/interfaces/activity';
 import { subscribeRuleNames } from '~/interfaces/in-app-notification';
 import { subscribeRuleNames } from '~/interfaces/in-app-notification';
-import { generateDefaultPreNotify } from '~/server/service/preNotify';
+import { generatePreNotify } from '~/server/service/preNotify';
 import loggerFactory from '~/utils/logger';
 import loggerFactory from '~/utils/logger';
 
 
 import { generateAddActivityMiddleware } from '../../middlewares/add-activity';
 import { generateAddActivityMiddleware } from '../../middlewares/add-activity';
@@ -851,7 +851,7 @@ module.exports = (crowi) => {
         action: SupportedAction.ACTION_PAGE_DUPLICATE,
         action: SupportedAction.ACTION_PAGE_DUPLICATE,
       };
       };
 
 
-      activityEvent.emit('update', res.locals.activity._id, parameters, page, generateDefaultPreNotify);
+      activityEvent.emit('update', res.locals.activity._id, parameters, page, generatePreNotify);
 
 
       return res.apiv3(result);
       return res.apiv3(result);
     });
     });

+ 2 - 2
apps/app/src/server/routes/page.js

@@ -7,7 +7,7 @@ import loggerFactory from '~/utils/logger';
 
 
 import { PathAlreadyExistsError } from '../models/errors';
 import { PathAlreadyExistsError } from '../models/errors';
 import UpdatePost from '../models/update-post';
 import UpdatePost from '../models/update-post';
-import { generateDefaultPreNotify } from '../service/preNotify';
+import { generatePreNotify } from '../service/preNotify';
 
 
 const { serializePageSecurely } = require('../models/serializers/page-serializer');
 const { serializePageSecurely } = require('../models/serializers/page-serializer');
 const { serializeRevisionSecurely } = require('../models/serializers/revision-serializer');
 const { serializeRevisionSecurely } = require('../models/serializers/revision-serializer');
@@ -524,7 +524,7 @@ module.exports = function(crowi, app) {
       action: SupportedAction.ACTION_PAGE_UPDATE,
       action: SupportedAction.ACTION_PAGE_UPDATE,
     };
     };
 
 
-    activityEvent.emit('update', res.locals.activity._id, parameters, { path: page.path, creator: page.creator._id.toString() }, generateDefaultPreNotify);
+    activityEvent.emit('update', res.locals.activity._id, parameters, { path: page.path, creator: page.creator._id.toString() }, generatePreNotify);
   };
   };
 
 
   /**
   /**

+ 10 - 10
apps/app/src/server/service/page.ts

@@ -46,7 +46,7 @@ import UserGroupRelation from '../models/user-group-relation';
 import { V5ConversionError } from '../models/vo/v5-conversion-error';
 import { V5ConversionError } from '../models/vo/v5-conversion-error';
 import { divideByType } from '../util/granted-group';
 import { divideByType } from '../util/granted-group';
 
 
-import { generateDefaultPreNotify, generatePreNotifyAlsoDescendants } from './preNotify';
+import { generatePreNotify } from './preNotify';
 
 
 const debug = require('debug')('growi:services:page');
 const debug = require('debug')('growi:services:page');
 
 
@@ -446,7 +446,7 @@ class PageService {
       throw err;
       throw err;
     }
     }
     if (page.descendantCount < 1) {
     if (page.descendantCount < 1) {
-      const preNotify = generateDefaultPreNotify(activity);
+      const preNotify = generatePreNotify(activity);
 
 
       this.activityEvent.emit('updated', activity, page, preNotify);
       this.activityEvent.emit('updated', activity, page, preNotify);
     }
     }
@@ -555,7 +555,7 @@ class PageService {
       await this.renameDescendantsWithStream(page, newPagePath, user, options, false, descendantsSubscribedSets);
       await this.renameDescendantsWithStream(page, newPagePath, user, options, false, descendantsSubscribedSets);
       const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
       const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
 
 
-      const preNotify = generatePreNotifyAlsoDescendants(activity, descendantsSubscribedUsers);
+      const preNotify = generatePreNotify(activity, () => { return descendantsSubscribedUsers });
 
 
       this.activityEvent.emit('updated', activity, page, preNotify);
       this.activityEvent.emit('updated', activity, page, preNotify);
     }
     }
@@ -1489,7 +1489,7 @@ class PageService {
       })();
       })();
     }
     }
     else {
     else {
-      const preNotify = generateDefaultPreNotify(activity);
+      const preNotify = generatePreNotify(activity);
 
 
       this.activityEvent.emit('updated', activity, page, preNotify);
       this.activityEvent.emit('updated', activity, page, preNotify);
     }
     }
@@ -1529,7 +1529,7 @@ class PageService {
 
 
     const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
     const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
 
 
-    const preNotify = generatePreNotifyAlsoDescendants(activity, descendantsSubscribedUsers);
+    const preNotify = generatePreNotify(activity, () => { return descendantsSubscribedUsers });
 
 
     this.activityEvent.emit('updated', activity, page, preNotify);
     this.activityEvent.emit('updated', activity, page, preNotify);
 
 
@@ -1842,7 +1842,7 @@ class PageService {
       })();
       })();
     }
     }
     else {
     else {
-      const preNotify = generateDefaultPreNotify(activity);
+      const preNotify = generatePreNotify(activity);
 
 
       this.activityEvent.emit('updated', activity, page, preNotify);
       this.activityEvent.emit('updated', activity, page, preNotify);
     }
     }
@@ -1855,7 +1855,7 @@ class PageService {
     await this.deleteCompletelyDescendantsWithStream(page, user, options, false, descendantsSubscribedSets);
     await this.deleteCompletelyDescendantsWithStream(page, user, options, false, descendantsSubscribedSets);
     const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
     const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
 
 
-    const preNotify = generatePreNotifyAlsoDescendants(activity, descendantsSubscribedUsers);
+    const preNotify = generatePreNotify(activity, () => { return descendantsSubscribedUsers });
 
 
     this.activityEvent.emit('updated', activity, page, preNotify);
     this.activityEvent.emit('updated', activity, page, preNotify);
 
 
@@ -1902,7 +1902,7 @@ class PageService {
     const pages = await this.deleteCompletelyDescendantsWithStream(page, user, options, true, descendantsSubscribedSets);
     const pages = await this.deleteCompletelyDescendantsWithStream(page, user, options, true, descendantsSubscribedSets);
     const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
     const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
 
 
-    const preNotify = generatePreNotifyAlsoDescendants(activity, descendantsSubscribedUsers);
+    const preNotify = generatePreNotify(activity, () => { return descendantsSubscribedUsers });
 
 
     this.activityEvent.emit('updated', activity, page, preNotify);
     this.activityEvent.emit('updated', activity, page, preNotify);
 
 
@@ -2182,7 +2182,7 @@ class PageService {
     if (!isRecursively) {
     if (!isRecursively) {
       await this.updateDescendantCountOfAncestors(parent._id, 1, true);
       await this.updateDescendantCountOfAncestors(parent._id, 1, true);
 
 
-      const preNotify = generateDefaultPreNotify(activity);
+      const preNotify = generatePreNotify(activity);
 
 
       this.activityEvent.emit('updated', activity, page, preNotify);
       this.activityEvent.emit('updated', activity, page, preNotify);
     }
     }
@@ -2232,7 +2232,7 @@ class PageService {
     await this.revertDeletedDescendantsWithStream(page, user, options, false, descendantsSubscribedSets);
     await this.revertDeletedDescendantsWithStream(page, user, options, false, descendantsSubscribedSets);
     const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
     const descendantsSubscribedUsers = Array.from(descendantsSubscribedSets) as Ref<IUser>[];
 
 
-    const preNotify = generatePreNotifyAlsoDescendants(activity, descendantsSubscribedUsers);
+    const preNotify = generatePreNotify(activity, () => { return descendantsSubscribedUsers });
 
 
     this.activityEvent.emit('updated', activity, page, preNotify);
     this.activityEvent.emit('updated', activity, page, preNotify);