shinoka7 6 лет назад
Родитель
Сommit
f9d2a2fa8a
3 измененных файлов с 2 добавлено и 9 удалено
  1. 0 7
      src/server/models/attachment.js
  2. 1 1
      src/server/models/user.js
  3. 1 1
      src/server/routes/attachment.js

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

@@ -97,13 +97,6 @@ module.exports = function(crowi) {
     // retrieve data from DB to get a completely populated instance
     const attachment = await this.findById(id);
     await fileUploader.deleteFile(attachment);
-    // remove the image attachment from all user(s)
-    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.removeWithSubstanceId(this.imageAttachment._id);
+      Attachment.removeWithSubstanceById(this.imageAttachment._id);
     }
 
     this.imageAttachment = undefined;

+ 1 - 1
src/server/routes/attachment.js

@@ -330,7 +330,7 @@ module.exports = function(crowi, app) {
     }
 
     try {
-      await Attachment.removeWithSubstanceById(id);
+      req.user.deleteImage();
     }
     catch (err) {
       return res.status(500).json(ApiResponse.error('Error while deleting file'));