From 04cdb04ee2d80ce37a7fd6d8e7dfa47cff539d8f Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 8 Apr 2018 07:11:29 +0900 Subject: [PATCH] Fix bug --- src/remote/activitypub/act/create/image.ts | 2 +- src/remote/activitypub/act/create/note.ts | 10 ++++------ .../api/endpoints/drive/files/upload_from_url.ts | 4 ---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/remote/activitypub/act/create/image.ts b/src/remote/activitypub/act/create/image.ts index c87423c5f..f1462f4ee 100644 --- a/src/remote/activitypub/act/create/image.ts +++ b/src/remote/activitypub/act/create/image.ts @@ -12,7 +12,7 @@ export default async function(actor: IRemoteUser, image): Promise { throw new Error('invalid image'); } - log(`Creating the Image: ${image.id}`); + log(`Creating the Image: ${image.url}`); return await uploadFromUrl(image.url, actor); } diff --git a/src/remote/activitypub/act/create/note.ts b/src/remote/activitypub/act/create/note.ts index 572a293ab..599bc10aa 100644 --- a/src/remote/activitypub/act/create/note.ts +++ b/src/remote/activitypub/act/create/note.ts @@ -37,15 +37,13 @@ export default async function createNote(resolver: Resolver, actor: IRemoteUser, //#endergion //#region 添付メディア - const media = []; + let media = []; if ('attachment' in note && note.attachment != null) { // TODO: attachmentは必ずしもImageではない // TODO: attachmentは必ずしも配列ではない - // TODO: ループの中でawaitはすべきでない - note.attachment.forEach(async media => { - const created = await createImage(note.actor, media); - media.push(created); - }); + media = await Promise.all(note.attachment.map(x => { + return createImage(actor, x); + })); } //#endregion diff --git a/src/server/api/endpoints/drive/files/upload_from_url.ts b/src/server/api/endpoints/drive/files/upload_from_url.ts index 9ebc8b823..8a426c0ef 100644 --- a/src/server/api/endpoints/drive/files/upload_from_url.ts +++ b/src/server/api/endpoints/drive/files/upload_from_url.ts @@ -7,10 +7,6 @@ import uploadFromUrl from '../../../../../services/drive/upload-from-url'; /** * Create a file from a URL - * - * @param {any} params - * @param {any} user - * @return {Promise} */ module.exports = async (params, user): Promise => { // Get 'url' parameter