improve performance of /v1/accounts/relationships
This commit is contained in:
parent
f5be341acc
commit
de26ffd60b
3 changed files with 14 additions and 12 deletions
|
|
@ -154,14 +154,11 @@ export class ApiAccountMastodon {
|
|||
reply.send(response);
|
||||
});
|
||||
|
||||
fastify.get<ApiAccountMastodonRoute & { Querystring: { id?: string | string[], 'id[]'?: string | string[] }}>('/v1/accounts/relationships', async (_request, reply) => {
|
||||
let ids = _request.query['id[]'] ?? _request.query['id'] ?? [];
|
||||
if (typeof ids === 'string') {
|
||||
ids = [ids];
|
||||
}
|
||||
fastify.get<ApiAccountMastodonRoute & { Querystring: { id?: string | string[] }}>('/v1/accounts/relationships', async (_request, reply) => {
|
||||
if (!_request.query.id) return reply.code(400).send({ error: 'BAD_REQUEST', error_description: 'Missing required property "id"' });
|
||||
|
||||
const client = this.clientService.getClient(_request);
|
||||
const data = await client.getRelationships(ids);
|
||||
const data = await client.getRelationships(_request.query.id);
|
||||
const response = data.data.map(relationship => convertRelationship(relationship));
|
||||
|
||||
reply.send(response);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue