partially fix Mastodon API

This commit is contained in:
naskya 2023-10-05 00:56:56 +09:00
parent 9050bda353
commit 92758a29f1
No known key found for this signature in database
GPG Key ID: 164DFF24E2D40139
3 changed files with 8 additions and 3 deletions

View File

@ -24,7 +24,11 @@ export function getClient(
const accessTokenArr = authorization?.split(" ") ?? [null]; const accessTokenArr = authorization?.split(" ") ?? [null];
const accessToken = accessTokenArr[accessTokenArr.length - 1]; const accessToken = accessTokenArr[accessTokenArr.length - 1];
const generator = (megalodon as any).default; 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; return client;
} }

View File

@ -68,7 +68,7 @@ export function apiAuthMastodon(router: Router): void {
website: body.website, website: body.website,
redirect_uri: red, redirect_uri: red,
client_id: Buffer.from(appData.url || "").toString("base64"), client_id: Buffer.from(appData.url || "").toString("base64"),
client_secret: appData.clientSecret, client_secret: appData.client_secret,
}; };
console.log(returns); console.log(returns);
ctx.body = returns; ctx.body = returns;

View File

@ -165,7 +165,8 @@ mastoRouter.post("/oauth/token", async (ctx) => {
} }
let client_id: Array<string> | string | null = body.client_id; let client_id: Array<string> | string | null = body.client_id;
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; 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; let token = null;
if (body.code) { 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})/); //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})/);