From aaa3a34d601fb7a11ca46bfecf8425cd79772165 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Mon, 25 Sep 2023 12:37:58 +0200 Subject: [PATCH] chore: swap base_url getting on some endpoints --- .../api/mastodon/MastodonApiServerService.ts | 2 +- .../src/server/api/mastodon/endpoints/account.ts | 3 +-- packages/megalodon/src/misskey.ts | 14 +++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts b/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts index cd0fe2433d..128cb3491a 100644 --- a/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts +++ b/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts @@ -93,7 +93,7 @@ export class MastodonApiServerService { }, order: { id: 'ASC' }, }); - const contact = admin == null ? null : convertAccount((await client.getAccount(admin.id, BASE_URL)).data); + const contact = admin == null ? null : convertAccount((await client.getAccount(admin.id)).data); reply.send(await getInstance(data.data, contact, this.config, await this.metaService.fetch())); } catch (e: any) { /* console.error(e); */ diff --git a/packages/backend/src/server/api/mastodon/endpoints/account.ts b/packages/backend/src/server/api/mastodon/endpoints/account.ts index 0e93583533..b9e9cb862f 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/account.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/account.ts @@ -106,8 +106,7 @@ export class ApiAccountMastodon { try { const data = await this.client.getAccountStatuses( convertId((this.request.params as any).id, IdType.SharkeyId), - convertTimelinesArgsId(argsToBools(limitToInt(this.request.query as any))), - this.BASE_URL, + convertTimelinesArgsId(argsToBools(limitToInt(this.request.query as any))) ); return data.data.map((status) => convertStatus(status)); } catch (e: any) { diff --git a/packages/megalodon/src/misskey.ts b/packages/megalodon/src/misskey.ts index 2f2cf3b9c9..6d0b543c41 100644 --- a/packages/megalodon/src/misskey.ts +++ b/packages/megalodon/src/misskey.ts @@ -266,14 +266,14 @@ export default class Misskey implements MegalodonInterface { /** * POST /api/users/show */ - public async getAccount(id: string, host?: string): Promise> { + public async getAccount(id: string): Promise> { return this.client .post('/api/users/show', { userId: id }) .then(res => { return Object.assign(res, { - data: MisskeyAPI.Converter.userDetail(res.data, host) + data: MisskeyAPI.Converter.userDetail(res.data, this.baseUrl) }) }) } @@ -301,7 +301,7 @@ export default class Misskey implements MegalodonInterface { }) .then(res => { if (res.data.pinnedNotes) { - return { ...res, data: res.data.pinnedNotes.map(n => MisskeyAPI.Converter.note(n, host)) } + return { ...res, data: res.data.pinnedNotes.map(n => MisskeyAPI.Converter.note(n, this.baseUrl)) } } return { ...res, data: [] } }) @@ -630,7 +630,7 @@ export default class Misskey implements MegalodonInterface { } return this.client.post>('/api/users/search', params).then(res => { return Object.assign(res, { - data: res.data.map(u => MisskeyAPI.Converter.userDetail(u)) + data: res.data.map(u => MisskeyAPI.Converter.userDetail(u, this.baseUrl)) }) }) } @@ -1225,14 +1225,14 @@ export default class Misskey implements MegalodonInterface { })) } - public async getStatusFavouritedBy(_id: string, host?: string): Promise>> { + public async getStatusFavouritedBy(_id: string): Promise>> { return this.client.post>("/api/notes/reactions", { noteId: _id, }) .then(async (res) => ({ ...res, data: ( - await Promise.all(res.data.map((n) => this.getAccount(n.user.id, host))) + await Promise.all(res.data.map((n) => this.getAccount(n.user.id))) ).map((p) => p.data), })); } @@ -2059,7 +2059,7 @@ export default class Misskey implements MegalodonInterface { return this.client.post>('/api/users/search', params).then(res => ({ ...res, data: { - accounts: res.data.map(u => MisskeyAPI.Converter.userDetail(u)), + accounts: res.data.map(u => MisskeyAPI.Converter.userDetail(u, this.baseUrl)), statuses: [], hashtags: [] }