2
0
shinoka7 6 жил өмнө
parent
commit
90872b7638

+ 7 - 0
src/server/models/attachment.js

@@ -97,6 +97,13 @@ module.exports = function(crowi) {
     // retrieve data from DB to get a completely populated instance
     const attachment = await this.findById(id);
     await fileUploader.deleteFile(attachment);
+    const User = await crowi.model('User');
+    await User.update({ imageAttachment: id }, {
+      $set: {
+        imageAttachment: undefined,
+      },
+    }, { multi: true });
+
     return await attachment.remove();
   };
 

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

@@ -227,7 +227,7 @@ module.exports = function(crowi) {
     this.image = undefined;
 
     if (this.imageAttachment != null) {
-      Attachment.removeWithSubstance(this.imageAttachment._id);
+      Attachment.removeWithSubstanceId(this.imageAttachment._id);
     }
 
     this.imageAttachment = undefined;