|
|
@@ -489,15 +489,19 @@ class PageService {
|
|
|
* Duplicate
|
|
|
*/
|
|
|
async duplicate(page, newPagePath, user, isRecursively) {
|
|
|
- const isPageMigrated = page.parent != null;
|
|
|
+ const Page = mongoose.model('Page') as unknown as PageModel;
|
|
|
+ const PageTagRelation = mongoose.model('PageTagRelation') as any; // TODO: Typescriptize model
|
|
|
+
|
|
|
// v4 compatible process
|
|
|
+ const isPageMigrated = page.parent != null;
|
|
|
const isV5Compatible = this.crowi.configManager.getConfig('crowi', 'app:isV5Compatible');
|
|
|
- if (!isV5Compatible || !isPageMigrated) {
|
|
|
+ const isRoot = isTopPage(page.path);
|
|
|
+ const isPageRestricted = page.grant === Page.GRANT_RESTRICTED;
|
|
|
+ const shouldUseV4Process = !isV5Compatible || !isPageMigrated || !isRoot || isPageRestricted;
|
|
|
+ if (shouldUseV4Process) {
|
|
|
return this.duplicateV4(page, newPagePath, user, isRecursively);
|
|
|
}
|
|
|
|
|
|
- const Page = mongoose.model('Page') as unknown as PageModel;
|
|
|
- const PageTagRelation = mongoose.model('PageTagRelation') as any; // TODO: Typescriptize model
|
|
|
// populate
|
|
|
await page.populate({ path: 'revision', model: 'Revision', select: 'body' });
|
|
|
|