From 90b666e626371ad91db9a07cb59176f95e35e2ac Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Sun, 29 Oct 2023 02:20:05 +0200 Subject: [PATCH] fix: await all results on favourites and reblogged --- packages/backend/src/server/api/mastodon/endpoints/account.ts | 4 +--- packages/backend/src/server/api/mastodon/endpoints/status.ts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/endpoints/account.ts b/packages/backend/src/server/api/mastodon/endpoints/account.ts index f2525c723f..a1f3773fd4 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/account.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/account.ts @@ -98,9 +98,7 @@ export class ApiAccountMastodon { public async getStatuses() { try { const data = await this.client.getAccountStatuses((this.request.params as any).id, argsToBools(limitToInt(this.request.query as any))); - const a = await Promise.all(data.data.map(async (status) => await this.mastoconverter.convertStatus(status))); - console.error(a); - return a; + return await Promise.all(data.data.map(async (status) => await this.mastoconverter.convertStatus(status))); } catch (e: any) { console.error(e); console.error(e.response.data); diff --git a/packages/backend/src/server/api/mastodon/endpoints/status.ts b/packages/backend/src/server/api/mastodon/endpoints/status.ts index 294d38f200..e5202244ea 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/status.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/status.ts @@ -89,7 +89,7 @@ export class ApiStatusMastodon { const client = getClient(BASE_URL, accessTokens); try { const data = await client.getStatusRebloggedBy(_request.params.id); - reply.send(data.data.map((account: Entity.Account) => this.mastoconverter.convertAccount(account))); + reply.send(await Promise.all(data.data.map(async (account: Entity.Account) => await this.mastoconverter.convertAccount(account)))); } catch (e: any) { console.error(e); reply.code(401).send(e.response.data); @@ -104,7 +104,7 @@ export class ApiStatusMastodon { const client = getClient(BASE_URL, accessTokens); try { const data = await client.getStatusFavouritedBy(_request.params.id); - reply.send(data.data.map((account: Entity.Account) => this.mastoconverter.convertAccount(account))); + reply.send(await Promise.all(data.data.map(async (account: Entity.Account) => await this.mastoconverter.convertAccount(account)))); } catch (e: any) { console.error(e); reply.code(401).send(e.response.data);