mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 10:33:08 +02:00
Resolve #2560
This commit is contained in:
parent
d86d5feae3
commit
fd06fd4dc1
1 changed files with 4 additions and 15 deletions
|
@ -132,25 +132,14 @@ export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (
|
|||
let files: IDriveFile[] = [];
|
||||
const fileIds = ps.fileIds != null ? ps.fileIds : ps.mediaIds != null ? ps.mediaIds : null;
|
||||
if (fileIds != null) {
|
||||
// Fetch files
|
||||
// forEach だと途中でエラーなどがあっても return できないので
|
||||
// 敢えて for を使っています。
|
||||
for (const fileId of fileIds) {
|
||||
// Fetch file
|
||||
// SELECT _id
|
||||
const entity = await DriveFile.findOne({
|
||||
files = await Promise.all(fileIds.map(fileId => {
|
||||
return DriveFile.findOne({
|
||||
_id: fileId,
|
||||
'metadata.userId': user._id
|
||||
});
|
||||
}));
|
||||
|
||||
if (entity === null) {
|
||||
return rej('file not found');
|
||||
} else {
|
||||
files.push(entity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
files = null;
|
||||
files = files.filter(file => file != null);
|
||||
}
|
||||
|
||||
let renote: INote = null;
|
||||
|
|
Loading…
Reference in a new issue