[mastodon-client] GET /v1/accounts/search

This commit is contained in:
Laura Hausmann 2023-10-08 01:19:33 +02:00
parent c7d62223ef
commit 0f17691f00
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -5,6 +5,7 @@ import { NoteConverter } from "@/server/api/mastodon/converters/note.js";
import { UserHelpers } from "@/server/api/mastodon/helpers/user.js";
import { ListHelpers } from "@/server/api/mastodon/helpers/list.js";
import { auth } from "@/server/api/mastodon/middleware/auth.js";
import { SearchHelpers } from "@/server/api/mastodon/helpers/search.js";
export function setupEndpointsAccount(router: Router): void {
router.get("/v1/accounts/verify_credentials",
@ -33,6 +34,15 @@ export function setupEndpointsAccount(router: Router): void {
ctx.body = await UserHelpers.getUserRelationhipToMany(ids, ctx.user.id);
}
);
// This must come before /accounts/:id, otherwise that will take precedence
router.get("/v1/accounts/search",
auth(true, ['read:accounts']),
async (ctx) => {
const args = normalizeUrlQuery(argsToBools(limitToInt(ctx.query), ['resolve', 'following']));
ctx.body = await SearchHelpers.search(args.q, 'accounts', args.resolve, args.following, undefined, false, undefined, undefined, args.limit, args.offset, ctx)
.then(p => p.accounts);
}
);
router.get<{ Params: { id: string } }>("/v1/accounts/:id",
auth(false),
async (ctx) => {