make relationshiops work

This commit is contained in:
CutestNekoAqua 2023-02-18 17:14:16 +01:00
parent 09ad8b9621
commit 22ce676cf9
1 changed files with 4 additions and 3 deletions

View File

@ -98,7 +98,7 @@ export function apiAccountMastodon(router: Router): void {
ctx.body = e.response.data; ctx.body = e.response.data;
} }
}); });
router.get<{ Params: { id: string } }>("/v1/accounts/:id", async (ctx) => { router.get<{ Params: { id: string } }>("/v1/accounts/:id(^.*\\d.*$)", async (ctx) => {
const BASE_URL = `${ctx.protocol}://${ctx.hostname}`; const BASE_URL = `${ctx.protocol}://${ctx.hostname}`;
const accessTokens = ctx.headers.authorization; const accessTokens = ctx.headers.authorization;
const client = getClient(BASE_URL, accessTokens); const client = getClient(BASE_URL, accessTokens);
@ -304,11 +304,12 @@ export function apiAccountMastodon(router: Router): void {
const client = getClient(BASE_URL, accessTokens); const client = getClient(BASE_URL, accessTokens);
let users; let users;
try { try {
const idsRaw = ctx.request.body ? ["id[]"] : null; // TODO: this should be body
const idsRaw = ctx.request.query ? ["id[]"] : null;
const ids = typeof idsRaw === "string" ? [idsRaw] : idsRaw; const ids = typeof idsRaw === "string" ? [idsRaw] : idsRaw;
users = ids; users = ids;
relationshopModel.id = idsRaw?.toString() || "1"; relationshopModel.id = idsRaw?.toString() || "1";
if (!(idsRaw && ids)) { if (!idsRaw) {
ctx.body = [relationshopModel]; ctx.body = [relationshopModel];
return; return;
} }