yuken %!s(int64=4) %!d(string=hai) anos
pai
achega
f21a41ed6c
Modificáronse 1 ficheiros con 8 adicións e 7 borrados
  1. 8 7
      packages/app/src/server/service/page.ts

+ 8 - 7
packages/app/src/server/service/page.ts

@@ -2263,25 +2263,26 @@ class PageService {
     return;
     return;
   }
   }
 
 
-  normalizeParentByPageIds(pageIds: ObjectIdLike[], user): void {
-    const Page = mongoose.model('Page') as unknown as PageModel;
+  async normalizeParentByPageIds(pageIds: ObjectIdLike[], user): Promise<void> {
+    const Page = await mongoose.model('Page') as unknown as PageModel;
 
 
     const socket = this.crowi.socketIoService.getDefaultSocket();
     const socket = this.crowi.socketIoService.getDefaultSocket();
 
 
-    for (const pageId of pageIds) {
-      const page = Page.findById(pageId);
-      const errorData: PageMigrationErrorData = { path: page.path };
+    for await (const pageId of pageIds) {
+      const page = await Page.findById(pageId);
       if (page == null) {
       if (page == null) {
         continue;
         continue;
       }
       }
 
 
+      const errorData = { path: page.path };
+
       try {
       try {
-        const canOperate = this.crowi.pageOperationService.canOperate(false, page.path, page.path);
+        const canOperate = await this.crowi.pageOperationService.canOperate(false, page.path, page.path);
         if (!canOperate) {
         if (!canOperate) {
           throw Error(`Cannot operate normalizeParent to path "${page.path}" right now.`);
           throw Error(`Cannot operate normalizeParent to path "${page.path}" right now.`);
         }
         }
 
 
-        const normalizedPage = this.normalizeParentByPage(page, user);
+        const normalizedPage = await this.normalizeParentByPage(page, user);
 
 
         if (normalizedPage == null) {
         if (normalizedPage == null) {
           socket.emit(SocketEventName.PageMigrationError, errorData);
           socket.emit(SocketEventName.PageMigrationError, errorData);