|
|
@@ -1,3 +1,5 @@
|
|
|
+import type { Readable } from 'node:stream';
|
|
|
+import { pipeline } from 'node:stream/promises';
|
|
|
import type {
|
|
|
IDataWithMeta,
|
|
|
IPage,
|
|
|
@@ -19,10 +21,8 @@ import { convertToNewAffiliationPath } from '@growi/core/dist/utils/page-path-ut
|
|
|
import { normalizePath } from '@growi/core/dist/utils/path-utils';
|
|
|
import type { HydratedDocument } from 'mongoose';
|
|
|
import mongoose from 'mongoose';
|
|
|
-import path from 'path';
|
|
|
+import path from 'pathe';
|
|
|
import sanitize from 'sanitize-filename';
|
|
|
-import type { Readable } from 'stream';
|
|
|
-import { pipeline } from 'stream/promises';
|
|
|
|
|
|
import { SupportedAction, SupportedTargetModel } from '~/interfaces/activity';
|
|
|
import type { IPageGrantData } from '~/interfaces/page';
|
|
|
@@ -640,7 +640,7 @@ module.exports = (crowi: Crowi) => {
|
|
|
* isGrantNormalized:
|
|
|
* type: boolean
|
|
|
* 400:
|
|
|
- * description: Bad request. Page is unreachable or empty.
|
|
|
+ * description: Bad request. Page is unreachable.
|
|
|
* 500:
|
|
|
* description: Internal server error.
|
|
|
*/
|
|
|
@@ -656,15 +656,12 @@ module.exports = (crowi: Crowi) => {
|
|
|
const Page = mongoose.model<IPage, PageModel>('Page');
|
|
|
const pageGrantService = crowi.pageGrantService as IPageGrantService;
|
|
|
|
|
|
- const page = await Page.findByIdAndViewer(pageId, req.user, null, false);
|
|
|
+ const page = await Page.findByIdAndViewer(pageId, req.user, null, true);
|
|
|
|
|
|
if (page == null) {
|
|
|
// Empty page should not be related to grant API
|
|
|
return res.apiv3Err(
|
|
|
- new ErrorV3(
|
|
|
- 'Page is unreachable or empty.',
|
|
|
- 'page_unreachable_or_empty',
|
|
|
- ),
|
|
|
+ new ErrorV3('Page is unreachable', 'page_unreachable'),
|
|
|
400,
|
|
|
);
|
|
|
}
|
|
|
@@ -708,7 +705,7 @@ module.exports = (crowi: Crowi) => {
|
|
|
getIdForRef(page.parent),
|
|
|
req.user,
|
|
|
null,
|
|
|
- false,
|
|
|
+ true,
|
|
|
);
|
|
|
|
|
|
// user isn't allowed to see parent's grant
|
|
|
@@ -866,7 +863,7 @@ module.exports = (crowi: Crowi) => {
|
|
|
* items:
|
|
|
* type: string
|
|
|
* 400:
|
|
|
- * description: Bad request. Page is unreachable or empty.
|
|
|
+ * description: Bad request. Page is unreachable.
|
|
|
* 500:
|
|
|
* description: Internal server error.
|
|
|
*/
|
|
|
@@ -880,15 +877,12 @@ module.exports = (crowi: Crowi) => {
|
|
|
const { pageId } = req.query;
|
|
|
|
|
|
const Page = mongoose.model<IPage, PageModel>('Page');
|
|
|
- const page = await Page.findByIdAndViewer(pageId, req.user, null);
|
|
|
+ const page = await Page.findByIdAndViewer(pageId, req.user, null, true);
|
|
|
|
|
|
if (page == null) {
|
|
|
// Empty page should not be related to grant API
|
|
|
return res.apiv3Err(
|
|
|
- new ErrorV3(
|
|
|
- 'Page is unreachable or empty.',
|
|
|
- 'page_unreachable_or_empty',
|
|
|
- ),
|
|
|
+ new ErrorV3('Page is unreachable', 'page_unreachable'),
|
|
|
400,
|
|
|
);
|
|
|
}
|