Taichi Masuyama 4 éve
szülő
commit
67316a59b4

+ 1 - 1
packages/app/src/server/models/obsolete-page.js

@@ -738,7 +738,7 @@ export const getPageSchema = (crowi) => {
     return await findListFromBuilderAndViewer(builder, currentUser, showAnyoneKnowsLink, opt);
   };
 
-  pageSchema.statics.findListByPageIds = async function(ids, option, excludeRedirect = true) {
+  pageSchema.statics.findListByPageIds = async function(ids, option) {
     const User = crowi.model('User');
 
     const opt = Object.assign({}, option);

+ 4 - 0
packages/app/src/server/models/page-redirect.ts

@@ -26,4 +26,8 @@ const schema = new Schema<PageRedirectDocument, PageRedirectModel>({
   toPath: { type: String, required: true },
 });
 
+schema.statics.removePageRedirectByFromPath = async function(fromPath: string): Promise<void> {
+  return this.deleteOne({ fromPath });
+};
+
 export default getOrCreateModel<PageRedirectDocument, PageRedirectModel>('PageRedirect', schema);

+ 4 - 4
packages/app/src/server/routes/page.js

@@ -1349,18 +1349,18 @@ module.exports = function(crowi, app) {
    * @apiParam {String} revision_id
    */
   api.unlink = async function(req, res) {
-    const path = req.body.path;
+    const fromPath = req.body.path;
 
     try {
-      await Page.removeRedirectOriginPageByPath(path);
-      logger.debug('Redirect Page deleted', path);
+      await PageRedirect.removePageRedirectByFromPath(fromPath);
+      logger.debug('Redirect Page deleted', fromPath);
     }
     catch (err) {
       logger.error('Error occured while get setting', err);
       return res.json(ApiResponse.error('Failed to delete redirect page.'));
     }
 
-    const result = { path };
+    const result = { path: fromPath };
     return res.json(ApiResponse.success(result));
   };