Explorar o código

change to use alt variable

= %!s(int64=5) %!d(string=hai) anos
pai
achega
cdbf3b5e1d
Modificáronse 1 ficheiros con 8 adicións e 3 borrados
  1. 8 3
      src/server/routes/apiv3/page.js

+ 8 - 3
src/server/routes/apiv3/page.js

@@ -201,7 +201,6 @@ module.exports = (crowi) => {
   router.get('/export', validator.export, async(req, res) => {
   router.get('/export', validator.export, async(req, res) => {
     try {
     try {
       const { pageId = null, revisionId = null } = req.query;
       const { pageId = null, revisionId = null } = req.query;
-      let revisionIdFromPage;
 
 
       if (pageId == null) {
       if (pageId == null) {
         return res.apiv3Err(new ErrorV3('Should provided pageId or both pageId and revisionId.'));
         return res.apiv3Err(new ErrorV3('Should provided pageId or both pageId and revisionId.'));
@@ -217,14 +216,20 @@ module.exports = (crowi) => {
         return res.apiv3Err(new ErrorV3(`Haven't the right to see the page ${pageId}.`), 403);
         return res.apiv3Err(new ErrorV3(`Haven't the right to see the page ${pageId}.`), 403);
       }
       }
 
 
+
+      let revisionIdForFind;
       if (revisionId == null) {
       if (revisionId == null) {
         const Page = crowi.model('Page');
         const Page = crowi.model('Page');
         const page = await Page.findByIdAndViewer(pageId);
         const page = await Page.findByIdAndViewer(pageId);
-        revisionIdFromPage = page.revision;
+        revisionIdForFind = page.revision;
+      }
+      else {
+        revisionIdForFind = revisionId;
       }
       }
 
 
       const Revision = crowi.model('Revision');
       const Revision = crowi.model('Revision');
-      const revision = await Revision.findById([revisionId || revisionIdFromPage]);
+      const revision = Revision.findById(revisionIdForFind);
+
       const markdown = revision.body;
       const markdown = revision.body;
 
 
       return res.apiv3({ markdown });
       return res.apiv3({ markdown });