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

call findListwithDescendants() different place in revert process

Shunm634-source 3 лет назад
Родитель
Сommit
3cf961a9db

+ 4 - 7
packages/app/src/server/routes/page.js

@@ -1374,17 +1374,14 @@ module.exports = function(crowi, app) {
     let descendantPages;
     try {
       page = await Page.findByIdAndViewer(pageId, req.user);
-      const pages = await Page.findListWithDescendants(page.path, req.user);
-      descendantPages = pages.pages;
-      console.log('What are the descendant pages\n', descendantPages);
-      descendantPages.pop();
+      const bPages = await Page.findListWithDescendants(page.path, req.user);
       if (page == null) {
         throw new Error(`Page '${pageId}' is not found or forbidden`, 'notfound_or_forbidden');
       }
-      if (descendantPages == null && isRecursively) {
-        throw new Error(`Page '${pageId}' has no descendant pages`, 'notfound_or_forbidden');
-      }
       page = await crowi.pageService.revertDeletedPage(page, req.user, {}, isRecursively);
+      const pages = await Page.findListWithDescendants(page.path, req.user);
+      descendantPages = pages.pages;
+      descendantPages.pop();
     }
     catch (err) {
       if (err instanceof PathAlreadyExistsError) {

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

@@ -208,7 +208,6 @@ export default class InAppNotificationService {
         mentionedUsers = await this.crowi.commentService.getMentionedUsers(activity.event);
       }
       let notificationTargetUsers = await activity?.getNotificationTargetUsers();
-      console.log('What are the descendant pages and target users\n', descendantPages, notificationTargetUsers);
       if (descendantPages != null && descendantPages.length > 0) {
         const User = this.crowi.model('User');
         const targetDescendantsUsers = await Subscription.getSubscriptions(descendantPages);
@@ -218,7 +217,6 @@ export default class InAppNotificationService {
           status: User.STATUS_ACTIVE,
         }).distinct('_id'));
       }
-      console.log('Who are the target users?\n', notificationTargetUsers);
       const snapshot = stringifySnapshot(target as IPage);
       await this.upsertByActivity([...notificationTargetUsers, ...mentionedUsers], activity, snapshot);
       await this.emitSocketIo(notificationTargetUsers);