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

add code for backward compatibility against to GROWI v4.0.x

Yuki Takei 5 лет назад
Родитель
Сommit
ea2f4a65f6

+ 1 - 1
packages/growi-plugin-attachment-refs/package.json

@@ -1,6 +1,6 @@
 {
   "name": "growi-plugin-attachment-refs",
-  "version": "1.1.1",
+  "version": "2.0.0",
   "description": "GROWI Plugin to add ref/refimg/refs/refsimg tags",
   "keywords": [
     "growi",

+ 7 - 1
packages/growi-plugin-attachment-refs/src/server/routes/refs.js

@@ -84,12 +84,18 @@ module.exports = (crowi) => {
       return;
     }
 
+    let creatorPopulateOpt;
+    // set populate option for backward compatibility against to GROWI <= v4.0.x
+    if (User.IMAGE_POPULATION != null) {
+      creatorPopulateOpt = User.IMAGE_POPULATION;
+    }
+
     const attachment = await Attachment
       .findOne({
         page: page._id,
         originalName: fileName,
       })
-      .populate({ path: 'creator', select: User.USER_PUBLIC_FIELDS });
+      .populate({ path: 'creator', select: User.USER_PUBLIC_FIELDS, populate: creatorPopulateOpt });
 
     // not found
     if (attachment == null) {