shinoka7 6 lat temu
rodzic
commit
90872b7638
2 zmienionych plików z 8 dodań i 1 usunięć
  1. 7 0
      src/server/models/attachment.js
  2. 1 1
      src/server/models/user.js

+ 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;