Compare commits

...

2 Commits

Author SHA1 Message Date
Acid Chicken (硫酸鶏) d956491c4a
Update delete-file.ts 2019-02-23 17:20:24 +09:00
Acid Chicken (硫酸鶏) 33ad190524
Update delete-file.ts 2019-02-23 17:19:52 +09:00
1 changed files with 7 additions and 1 deletions

View File

@ -7,7 +7,7 @@ import perUserDriveChart from '../../services/chart/per-user-drive';
import instanceChart from '../../services/chart/instance';
import DriveFileWebpublic, { DriveFileWebpublicChunk } from '../../models/drive-file-webpublic';
import Instance from '../../models/instance';
import { isRemoteUser } from '../../models/user';
import User, { isRemoteUser } from '../../models/user';
export default async function(file: IDriveFile, isExpired = false) {
if (file.metadata.storage == 'minio') {
@ -56,6 +56,12 @@ export default async function(file: IDriveFile, isExpired = false) {
$set: set
});
await Promise.all(['avatarId', 'bannerId', 'wallpaperId']
.map(target => User.find({ [target]: file._id })
.then(x => Promise.all(x.map(x => User.update({ _id: x._id }, {
$unset: { [target]: file._id }
}))))));
//#region サムネイルもあれば削除
const thumbnail = await DriveFileThumbnail.findOne({
'metadata.originalId': file._id