Explorar o código

add createRedirectPage

itizawa %!s(int64=5) %!d(string=hai) anos
pai
achega
2510682a76
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      src/server/models/page.js

+ 4 - 1
src/server/models/page.js

@@ -1231,7 +1231,7 @@ module.exports = function(crowi) {
 
 
     const path = targetPage.path;
     const path = targetPage.path;
     const pathRegExp = new RegExp(`^${escapeStringRegexp(path)}`, 'i');
     const pathRegExp = new RegExp(`^${escapeStringRegexp(path)}`, 'i');
-    const updateMetadata = options.updateMetadata;
+    const { updateMetadata, createRedirectPage } = options;
 
 
     // sanitize path
     // sanitize path
     newPagePathPrefix = crowi.xss.process(newPagePathPrefix); // eslint-disable-line no-param-reassign
     newPagePathPrefix = crowi.xss.process(newPagePathPrefix); // eslint-disable-line no-param-reassign
@@ -1250,6 +1250,9 @@ module.exports = function(crowi) {
       else {
       else {
         unorderedBulkOp.find({ _id: page._id }).update({ $set: { path: newPagePath } });
         unorderedBulkOp.find({ _id: page._id }).update({ $set: { path: newPagePath } });
       }
       }
+      if (createRedirectPage) {
+        // unorderedBulkOp.insert({ redirectTo: newPagePath });
+      }
       revisionUnorderedBulkOp.find({ path: page.path }).update({ $set: { path: newPagePath } }, { multi: true });
       revisionUnorderedBulkOp.find({ path: page.path }).update({ $set: { path: newPagePath } }, { multi: true });
     });
     });