upd: add history endpoint, make sure all areas use new convertAccount
This commit is contained in:
parent
8fd669ff7d
commit
c53323d237
6 changed files with 104 additions and 28 deletions
|
|
@ -8,7 +8,7 @@ import { DI } from '@/di-symbols.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import type { Config } from '@/config.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import { convertAccount, convertAnnouncement, convertFilter, convertAttachment, convertFeaturedTag, convertList, MastoConverters } from './converters.js';
|
||||
import { convertAnnouncement, convertFilter, convertAttachment, convertFeaturedTag, convertList, MastoConverters } from './converters.js';
|
||||
import { getInstance } from './endpoints/meta.js';
|
||||
import { ApiAuthMastodon, ApiAccountMastodon, ApiFilterMastodon, ApiNotifyMastodon, ApiSearchMastodon, ApiTimelineMastodon, ApiStatusMastodon } from './endpoints.js';
|
||||
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';
|
||||
|
|
@ -102,8 +102,8 @@ export class MastodonApiServerService {
|
|||
},
|
||||
order: { id: 'ASC' },
|
||||
});
|
||||
const contact = admin == null ? null : convertAccount((await client.getAccount(admin.id)).data);
|
||||
reply.send(await getInstance(data.data, contact, this.config, await this.metaService.fetch()));
|
||||
const contact = admin == null ? null : await this.mastoConverter.convertAccount((await client.getAccount(admin.id)).data);
|
||||
reply.send(await getInstance(data.data, contact as Entity.Account, this.config, await this.metaService.fetch()));
|
||||
} catch (e: any) {
|
||||
/* console.error(e); */
|
||||
reply.code(401).send(e.response.data);
|
||||
|
|
@ -252,7 +252,7 @@ export class MastodonApiServerService {
|
|||
// displayed without being logged in
|
||||
try {
|
||||
const data = await client.updateCredentials(_request.body!);
|
||||
reply.send(convertAccount(data.data));
|
||||
reply.send(await this.mastoConverter.convertAccount(data.data));
|
||||
} catch (e: any) {
|
||||
/* console.error(e); */
|
||||
reply.code(401).send(e.response.data);
|
||||
|
|
@ -268,7 +268,7 @@ export class MastodonApiServerService {
|
|||
const data = await client.search((_request.query as any).acct, { type: 'accounts' });
|
||||
const profile = await this.userProfilesRepository.findOneBy({ userId: data.data.accounts[0].id });
|
||||
data.data.accounts[0].fields = profile?.fields.map(f => ({ ...f, verified_at: null })) || [];
|
||||
reply.send(convertAccount(data.data.accounts[0]));
|
||||
reply.send(await this.mastoConverter.convertAccount(data.data.accounts[0]));
|
||||
} catch (e: any) {
|
||||
/* console.error(e); */
|
||||
reply.code(401).send(e.response.data);
|
||||
|
|
@ -544,7 +544,7 @@ export class MastodonApiServerService {
|
|||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const data = await client.getFollowRequests( ((_request.query as any) || { limit: 20 }).limit );
|
||||
reply.send(data.data.map((account) => convertAccount(account as Entity.Account)));
|
||||
reply.send(await Promise.all(data.data.map(async (account) => await this.mastoConverter.convertAccount(account as Entity.Account))));
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
console.error(e.response.data); */
|
||||
|
|
@ -587,7 +587,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const search = new ApiSearchMastodon(_request, client, BASE_URL);
|
||||
const search = new ApiSearchMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await search.SearchV1());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -601,7 +601,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const search = new ApiSearchMastodon(_request, client, BASE_URL);
|
||||
const search = new ApiSearchMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await search.SearchV2());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -615,7 +615,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const search = new ApiSearchMastodon(_request, client, BASE_URL);
|
||||
const search = new ApiSearchMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await search.getStatusTrends());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -629,7 +629,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const search = new ApiSearchMastodon(_request, client, BASE_URL);
|
||||
const search = new ApiSearchMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await search.getSuggestions());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue