Explorar el Código

add imageattachmentpath to user public fields and update imageattachmentpath when update profile image ofuser

yusuketk hace 6 años
padre
commit
bb07a595d6
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  1. 4 1
      src/server/models/user.js

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

@@ -16,7 +16,8 @@ module.exports = function(crowi) {
   const STATUS_SUSPENDED = 3;
   const STATUS_SUSPENDED = 3;
   const STATUS_DELETED = 4;
   const STATUS_DELETED = 4;
   const STATUS_INVITED = 5;
   const STATUS_INVITED = 5;
-  const USER_PUBLIC_FIELDS = '_id image isEmailPublished isGravatarEnabled googleId name username email introduction status lang createdAt lastLoginAt admin';
+  const USER_PUBLIC_FIELDS = '_id image isEmailPublished isGravatarEnabled googleId name username email introduction'
+  + 'status lang createdAt lastLoginAt admin imageAttachmentPath';
   const IMAGE_POPULATION = { path: 'imageAttachment', select: 'filePathProxied' };
   const IMAGE_POPULATION = { path: 'imageAttachment', select: 'filePathProxied' };
 
 
   const LANG_EN = 'en';
   const LANG_EN = 'en';
@@ -226,6 +227,7 @@ module.exports = function(crowi) {
 
 
   userSchema.methods.updateImage = async function(attachment) {
   userSchema.methods.updateImage = async function(attachment) {
     this.imageAttachment = attachment;
     this.imageAttachment = attachment;
+    this.imageAttachmentPath = attachment.filePathProxied;
     return this.save();
     return this.save();
   };
   };
 
 
@@ -241,6 +243,7 @@ module.exports = function(crowi) {
     }
     }
 
 
     this.imageAttachment = undefined;
     this.imageAttachment = undefined;
+    this.imageAttachmentPath = undefined;
     return this.save();
     return this.save();
   };
   };