Răsfoiți Sursa

different style fix

shinoka7 6 ani în urmă
părinte
comite
f9d2a2fa8a

+ 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
     // retrieve data from DB to get a completely populated instance
     const attachment = await this.findById(id);
     const attachment = await this.findById(id);
     await fileUploader.deleteFile(attachment);
     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();
     return await attachment.remove();
   };
   };

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

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

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

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