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

Merge pull request #9868 from weseek/master

Release v7.2.2
Yuki Takei 11 месяцев назад
Родитель
Сommit
db2106b453
4 измененных файлов с 19 добавлено и 9 удалено
  1. 1 1
      apps/app/package.json
  2. 16 6
      apps/app/src/server/routes/apiv3/page/index.ts
  3. 1 1
      apps/slackbot-proxy/package.json
  4. 1 1
      package.json

+ 1 - 1
apps/app/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "@growi/app",
   "name": "@growi/app",
-  "version": "7.2.1",
+  "version": "7.2.2-RC.0",
   "license": "MIT",
   "license": "MIT",
   "private": "true",
   "private": "true",
   "scripts": {
   "scripts": {

+ 16 - 6
apps/app/src/server/routes/apiv3/page/index.ts

@@ -2,7 +2,7 @@ import path from 'path';
 import { type Readable } from 'stream';
 import { type Readable } from 'stream';
 import { pipeline } from 'stream/promises';
 import { pipeline } from 'stream/promises';
 
 
-import type { IPage } from '@growi/core';
+import type { IPage, IRevision } from '@growi/core';
 import {
 import {
   AllSubscriptionStatusType, PageGrant, SubscriptionStatusType,
   AllSubscriptionStatusType, PageGrant, SubscriptionStatusType,
   getIdForRef,
   getIdForRef,
@@ -157,7 +157,7 @@ module.exports = (crowi) => {
     ],
     ],
     export: [
     export: [
       query('format').isString().isIn(['md', 'pdf']),
       query('format').isString().isIn(['md', 'pdf']),
-      query('revisionId').isString(),
+      query('revisionId').optional().isMongoId(),
     ],
     ],
     archive: [
     archive: [
       body('rootPagePath').isString(),
       body('rootPagePath').isString(),
@@ -844,8 +844,10 @@ module.exports = (crowi) => {
   */
   */
   router.get('/export/:pageId', loginRequiredStrictly, validator.export, async(req, res) => {
   router.get('/export/:pageId', loginRequiredStrictly, validator.export, async(req, res) => {
     const pageId: string = req.params.pageId;
     const pageId: string = req.params.pageId;
-    const { format, revisionId = null } = req.query;
-    let revision;
+    const format: 'md' | 'pdf' = req.query.format ?? 'md';
+    const revisionId: string | undefined = req.query.revisionId;
+
+    let revision: HydratedDocument<IRevision> | null;
     let pagePath;
     let pagePath;
 
 
     const Page = mongoose.model<HydratedDocument<PageDocument>, PageModel>('Page');
     const Page = mongoose.model<HydratedDocument<PageDocument>, PageModel>('Page');
@@ -878,9 +880,17 @@ module.exports = (crowi) => {
     }
     }
 
 
     try {
     try {
-      const revisionIdForFind = revisionId ?? page.revision;
+      const targetId = revisionId ?? (page.revision != null ? getIdForRef(page.revision) : null);
+      if (targetId == null) {
+        throw new Error('revisionId is not specified');
+      }
+
+      const revisionIdForFind = new mongoose.Types.ObjectId(targetId);
+      revision = await Revision.findById(revisionIdForFind);
+      if (revision == null) {
+        throw new Error('Revision is not found');
+      }
 
 
-      revision = await Revision.findOne({ id: { $eq: revisionIdForFind } });
       pagePath = page.path;
       pagePath = page.path;
 
 
       // Error if pageId and revison's pageIds do not match
       // Error if pageId and revison's pageIds do not match

+ 1 - 1
apps/slackbot-proxy/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "@growi/slackbot-proxy",
   "name": "@growi/slackbot-proxy",
-  "version": "7.2.1-slackbot-proxy.0",
+  "version": "7.2.2-slackbot-proxy.0",
   "license": "MIT",
   "license": "MIT",
   "private": "true",
   "private": "true",
   "scripts": {
   "scripts": {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "growi",
   "name": "growi",
-  "version": "7.2.1",
+  "version": "7.2.2-RC.0",
   "description": "Team collaboration software using markdown",
   "description": "Team collaboration software using markdown",
   "license": "MIT",
   "license": "MIT",
   "private": "true",
   "private": "true",