From 92758a29f11dd6d8d664bb1947f3cca66548ac91 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 5 Oct 2023 00:56:56 +0900 Subject: [PATCH] partially fix Mastodon API --- .../src/server/api/mastodon/ApiMastodonCompatibleService.ts | 6 +++++- packages/backend/src/server/api/mastodon/endpoints/auth.ts | 2 +- packages/backend/src/server/index.ts | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts index 44485ac429..3f6e671bd6 100644 --- a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts +++ b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts @@ -24,7 +24,11 @@ export function getClient( const accessTokenArr = authorization?.split(" ") ?? [null]; const accessToken = accessTokenArr[accessTokenArr.length - 1]; const generator = (megalodon as any).default; - const client = generator(BASE_URL, accessToken) as MegalodonInterface; + const client = generator( + "firefish", + BASE_URL, + accessToken, + ) as MegalodonInterface; return client; } diff --git a/packages/backend/src/server/api/mastodon/endpoints/auth.ts b/packages/backend/src/server/api/mastodon/endpoints/auth.ts index b55cb6388c..3d6eb8c4d6 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/auth.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/auth.ts @@ -68,7 +68,7 @@ export function apiAuthMastodon(router: Router): void { website: body.website, redirect_uri: red, client_id: Buffer.from(appData.url || "").toString("base64"), - client_secret: appData.clientSecret, + client_secret: appData.client_secret, }; console.log(returns); ctx.body = returns; diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index 779e65ea59..b967754d46 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -165,7 +165,8 @@ mastoRouter.post("/oauth/token", async (ctx) => { } let client_id: Array | string | null = body.client_id; const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; - const client = megalodon("firefish", BASE_URL) as MegalodonInterface; + const generator = (megalodon as any).default; + const client = generator("firefish", BASE_URL, null) as MegalodonInterface; let token = null; if (body.code) { //m = body.code.match(/^([a-zA-Z0-9]{8})([a-zA-Z0-9]{4})([a-zA-Z0-9]{4})([a-zA-Z0-9]{4})([a-zA-Z0-9]{12})/);