merge: Implement /v1/accounts/search Mastodon API endpoint (!1138)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1138 Approved-by: Hazelnoot <acomputerdog@gmail.com> Approved-by: dakkar <dakkar@thenautilus.net>
This commit is contained in:
commit
b3d5165d53
2 changed files with 20 additions and 1 deletions
|
|
@ -153,6 +153,25 @@ export class ApiAccountMastodon {
|
|||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Querystring: { q: string; limit?: string; offset?: string; resolve?: string; following?: string; } }>('/v1/accounts/search', async (request, reply) => {
|
||||
if (!request.query.q) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "q"' });
|
||||
|
||||
const client = this.clientService.getClient(request);
|
||||
|
||||
const limit = request.query.limit ? parseInt(request.query.limit) : 40;
|
||||
|
||||
const options = {
|
||||
following: toBoolean(request.query.following),
|
||||
limit,
|
||||
resolve: toBoolean(request.query.resolve),
|
||||
};
|
||||
|
||||
const data = await client.searchAccount(request.query.q, options);
|
||||
const response = await Promise.all(data.data.map(async (account) => await this.mastoConverters.convertAccount(account)));
|
||||
|
||||
return reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<{ Params: { id?: string } }>('/v1/accounts/:id', async (_request, reply) => {
|
||||
if (!_request.params.id) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required parameter "id"' });
|
||||
|
||||
|
|
|
|||
|
|
@ -653,7 +653,7 @@ export default class Misskey implements MegalodonInterface {
|
|||
max_id?: string
|
||||
since_id?: string
|
||||
}
|
||||
): Promise<Response<Array<Entity.Account>> | any> {
|
||||
): Promise<Response<Array<Entity.Account>>> {
|
||||
let params = {
|
||||
query: q,
|
||||
detail: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue