Jelajahi Sumber

Merge branch 'master' into fix/5474-5486-pages-can-be-created-under-share-path

Yuki Takei 5 tahun lalu
induk
melakukan
3addf3f672
2 mengubah file dengan 22 tambahan dan 5 penghapusan
  1. 2 0
      CHANGES.md
  2. 20 5
      src/server/service/page.js

+ 2 - 0
CHANGES.md

@@ -7,6 +7,8 @@
     * browser-bunyan
     * browser-bunyan
 * Fix: Can create pages on the share route
 * Fix: Can create pages on the share route
     * Introduced by v4.2.8
     * Introduced by v4.2.8
+* Fix: Group page is excluded by recurrence operation
+    * Introduced by v4.2.8
 
 
 ## v4.2.13
 ## v4.2.13
 
 

+ 20 - 5
src/server/service/page.js

@@ -141,6 +141,9 @@ class PageService {
    */
    */
   async renameDescendantsWithStream(targetPage, newPagePath, user, options = {}) {
   async renameDescendantsWithStream(targetPage, newPagePath, user, options = {}) {
     const Page = this.crowi.model('Page');
     const Page = this.crowi.model('Page');
+    const UserGroupRelation = this.crowi.model('UserGroupRelation');
+
+    const userGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
     const newPagePathPrefix = newPagePath;
     const newPagePathPrefix = newPagePath;
     const { PageQueryBuilder } = Page;
     const { PageQueryBuilder } = Page;
     const pathRegExp = new RegExp(`^${escapeStringRegexp(targetPage.path)}`, 'i');
     const pathRegExp = new RegExp(`^${escapeStringRegexp(targetPage.path)}`, 'i');
@@ -148,7 +151,7 @@ class PageService {
     const readStream = new PageQueryBuilder(Page.find())
     const readStream = new PageQueryBuilder(Page.find())
       .addConditionToExcludeRedirect()
       .addConditionToExcludeRedirect()
       .addConditionToListOnlyDescendants(targetPage.path)
       .addConditionToListOnlyDescendants(targetPage.path)
-      .addConditionToFilteringByViewer(user)
+      .addConditionToFilteringByViewer(user, userGroups)
       .query
       .query
       .lean()
       .lean()
       .cursor({ batchSize: BULK_REINDEX_SIZE });
       .cursor({ batchSize: BULK_REINDEX_SIZE });
@@ -342,6 +345,9 @@ class PageService {
 
 
   async duplicateDescendantsWithStream(page, newPagePath, user) {
   async duplicateDescendantsWithStream(page, newPagePath, user) {
     const Page = this.crowi.model('Page');
     const Page = this.crowi.model('Page');
+    const UserGroupRelation = this.crowi.model('UserGroupRelation');
+
+    const userGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
     const newPagePathPrefix = newPagePath;
     const newPagePathPrefix = newPagePath;
     const pathRegExp = new RegExp(`^${escapeStringRegexp(page.path)}`, 'i');
     const pathRegExp = new RegExp(`^${escapeStringRegexp(page.path)}`, 'i');
 
 
@@ -350,7 +356,7 @@ class PageService {
     const readStream = new PageQueryBuilder(Page.find())
     const readStream = new PageQueryBuilder(Page.find())
       .addConditionToExcludeRedirect()
       .addConditionToExcludeRedirect()
       .addConditionToListOnlyDescendants(page.path)
       .addConditionToListOnlyDescendants(page.path)
-      .addConditionToFilteringByViewer(user)
+      .addConditionToFilteringByViewer(user, userGroups)
       .query
       .query
       .lean()
       .lean()
       .cursor({ batchSize: BULK_REINDEX_SIZE });
       .cursor({ batchSize: BULK_REINDEX_SIZE });
@@ -480,12 +486,15 @@ class PageService {
    */
    */
   async deleteDescendantsWithStream(targetPage, user, options = {}) {
   async deleteDescendantsWithStream(targetPage, user, options = {}) {
     const Page = this.crowi.model('Page');
     const Page = this.crowi.model('Page');
+    const UserGroupRelation = this.crowi.model('UserGroupRelation');
+
+    const userGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
     const { PageQueryBuilder } = Page;
     const { PageQueryBuilder } = Page;
 
 
     const readStream = new PageQueryBuilder(Page.find())
     const readStream = new PageQueryBuilder(Page.find())
       .addConditionToExcludeRedirect()
       .addConditionToExcludeRedirect()
       .addConditionToListOnlyDescendants(targetPage.path)
       .addConditionToListOnlyDescendants(targetPage.path)
-      .addConditionToFilteringByViewer(user)
+      .addConditionToFilteringByViewer(user, userGroups)
       .query
       .query
       .lean()
       .lean()
       .cursor({ batchSize: BULK_REINDEX_SIZE });
       .cursor({ batchSize: BULK_REINDEX_SIZE });
@@ -556,12 +565,15 @@ class PageService {
    */
    */
   async deleteCompletelyDescendantsWithStream(targetPage, user, options = {}) {
   async deleteCompletelyDescendantsWithStream(targetPage, user, options = {}) {
     const Page = this.crowi.model('Page');
     const Page = this.crowi.model('Page');
+    const UserGroupRelation = this.crowi.model('UserGroupRelation');
+
+    const userGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
     const { PageQueryBuilder } = Page;
     const { PageQueryBuilder } = Page;
 
 
     const readStream = new PageQueryBuilder(Page.find())
     const readStream = new PageQueryBuilder(Page.find())
       .addConditionToExcludeRedirect()
       .addConditionToExcludeRedirect()
       .addConditionToListOnlyDescendants(targetPage.path)
       .addConditionToListOnlyDescendants(targetPage.path)
-      .addConditionToFilteringByViewer(user)
+      .addConditionToFilteringByViewer(user, userGroups)
       .query
       .query
       .lean()
       .lean()
       .cursor({ batchSize: BULK_REINDEX_SIZE });
       .cursor({ batchSize: BULK_REINDEX_SIZE });
@@ -682,12 +694,15 @@ class PageService {
    */
    */
   async revertDeletedDescendantsWithStream(targetPage, user, options = {}) {
   async revertDeletedDescendantsWithStream(targetPage, user, options = {}) {
     const Page = this.crowi.model('Page');
     const Page = this.crowi.model('Page');
+    const UserGroupRelation = this.crowi.model('UserGroupRelation');
+
+    const userGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
     const { PageQueryBuilder } = Page;
     const { PageQueryBuilder } = Page;
 
 
     const readStream = new PageQueryBuilder(Page.find())
     const readStream = new PageQueryBuilder(Page.find())
       .addConditionToExcludeRedirect()
       .addConditionToExcludeRedirect()
       .addConditionToListOnlyDescendants(targetPage.path)
       .addConditionToListOnlyDescendants(targetPage.path)
-      .addConditionToFilteringByViewer(user)
+      .addConditionToFilteringByViewer(user, userGroups)
       .query
       .query
       .lean()
       .lean()
       .cursor({ batchSize: BULK_REINDEX_SIZE });
       .cursor({ batchSize: BULK_REINDEX_SIZE });