mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2025-03-04 07:18:50 -07:00
[mastodon-client] GET /accounts/:id
This commit is contained in:
parent
6606eda981
commit
d258789c34
1 changed files with 5 additions and 6 deletions
|
@ -12,6 +12,8 @@ import {
|
||||||
convertRelationship,
|
convertRelationship,
|
||||||
convertStatus,
|
convertStatus,
|
||||||
} from "../converters.js";
|
} from "../converters.js";
|
||||||
|
import { getNote, getUser } from "@/server/api/common/getters.js";
|
||||||
|
import { convertUser } from "@/server/api/mastodon/converters/user.js";
|
||||||
|
|
||||||
const relationshipModel = {
|
const relationshipModel = {
|
||||||
id: "",
|
id: "",
|
||||||
|
@ -131,13 +133,10 @@ export function apiAccountMastodon(router: Router): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
router.get<{ Params: { id: string } }>("/v1/accounts/:id", async (ctx) => {
|
router.get<{ Params: { id: string } }>("/v1/accounts/:id", async (ctx) => {
|
||||||
const BASE_URL = `${ctx.protocol}://${ctx.hostname}`;
|
|
||||||
const accessTokens = ctx.headers.authorization;
|
|
||||||
const client = getClient(BASE_URL, accessTokens);
|
|
||||||
try {
|
try {
|
||||||
const calcId = convertId(ctx.params.id, IdType.IceshrimpId);
|
const userId = convertId(ctx.params.id, IdType.IceshrimpId);
|
||||||
const data = await client.getAccount(calcId);
|
const account = await convertUser(await getUser(userId));
|
||||||
ctx.body = convertAccount(data.data);
|
ctx.body = convertAccount(account);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
console.error(e.response.data);
|
console.error(e.response.data);
|
||||||
|
|
Loading…
Add table
Reference in a new issue