mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-29 05:17:39 -07:00
[mastodon-client] Add stubs for featured_tags and followed_tags
This commit is contained in:
parent
4fe62e62c3
commit
d2c9238a18
1 changed files with 10 additions and 31 deletions
|
@ -1,8 +1,7 @@
|
||||||
import Router from "@koa/router";
|
import Router from "@koa/router";
|
||||||
import { getClient } from "../index.js";
|
|
||||||
import { argsToBools, convertPaginationArgsIds, limitToInt, normalizeUrlQuery } from "./timeline.js";
|
import { argsToBools, convertPaginationArgsIds, limitToInt, normalizeUrlQuery } from "./timeline.js";
|
||||||
import { convertId, IdType } from "../../index.js";
|
import { convertId, IdType } from "../../index.js";
|
||||||
import { convertAccount, convertFeaturedTag, convertList, convertRelationship, convertStatus, } from "../converters.js";
|
import { convertAccount, convertList, convertRelationship, convertStatus, } from "../converters.js";
|
||||||
import { getUser } from "@/server/api/common/getters.js";
|
import { getUser } from "@/server/api/common/getters.js";
|
||||||
import { UserConverter } from "@/server/api/mastodon/converters/user.js";
|
import { UserConverter } from "@/server/api/mastodon/converters/user.js";
|
||||||
import authenticate from "@/server/api/authenticate.js";
|
import authenticate from "@/server/api/authenticate.js";
|
||||||
|
@ -126,19 +125,11 @@ export function setupEndpointsAccount(router: Router): void {
|
||||||
router.get<{ Params: { id: string } }>(
|
router.get<{ Params: { id: string } }>(
|
||||||
"/v1/accounts/:id/featured_tags",
|
"/v1/accounts/:id/featured_tags",
|
||||||
async (ctx) => {
|
async (ctx) => {
|
||||||
const BASE_URL = `${ctx.protocol}://${ctx.hostname}`;
|
|
||||||
const accessTokens = ctx.headers.authorization;
|
|
||||||
const client = getClient(BASE_URL, accessTokens);
|
|
||||||
try {
|
try {
|
||||||
const data = await client.getAccountFeaturedTags(
|
ctx.body = [];
|
||||||
convertId(ctx.params.id, IdType.IceshrimpId),
|
|
||||||
);
|
|
||||||
ctx.body = data.data.map((tag) => convertFeaturedTag(tag));
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
ctx.status = 400;
|
||||||
console.error(e.response.data);
|
ctx.body = { error: e.message };
|
||||||
ctx.status = 401;
|
|
||||||
ctx.body = e.response.data;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -355,31 +346,19 @@ export function setupEndpointsAccount(router: Router): void {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
router.get("/v1/featured_tags", async (ctx) => {
|
router.get("/v1/featured_tags", async (ctx) => {
|
||||||
const BASE_URL = `${ctx.protocol}://${ctx.hostname}`;
|
|
||||||
const accessTokens = ctx.headers.authorization;
|
|
||||||
const client = getClient(BASE_URL, accessTokens);
|
|
||||||
try {
|
try {
|
||||||
const data = await client.getFeaturedTags();
|
ctx.body = [];
|
||||||
ctx.body = data.data.map((tag) => convertFeaturedTag(tag));
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
ctx.status = 400;
|
||||||
console.error(e.response.data);
|
ctx.body = { error: e.message };
|
||||||
ctx.status = 401;
|
|
||||||
ctx.body = e.response.data;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
router.get("/v1/followed_tags", async (ctx) => {
|
router.get("/v1/followed_tags", async (ctx) => {
|
||||||
const BASE_URL = `${ctx.protocol}://${ctx.hostname}`;
|
|
||||||
const accessTokens = ctx.headers.authorization;
|
|
||||||
const client = getClient(BASE_URL, accessTokens);
|
|
||||||
try {
|
try {
|
||||||
const data = await client.getFollowedTags();
|
ctx.body = [];
|
||||||
ctx.body = data.data;
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
ctx.status = 400;
|
||||||
console.error(e.response.data);
|
ctx.body = { error: e.message };
|
||||||
ctx.status = 401;
|
|
||||||
ctx.body = e.response.data;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
router.get("/v1/bookmarks", async (ctx) => {
|
router.get("/v1/bookmarks", async (ctx) => {
|
||||||
|
|
Loading…
Reference in a new issue