upd: simplify importing of mastoconverter, fix bug
Lets you import stuff into mastoconverter without needing to also import them everywhere else Fixes not being able to get statuses on accounts
This commit is contained in:
parent
f92773d995
commit
43f27a639f
6 changed files with 39 additions and 54 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 } from './converters.js';
|
||||
import { convertAccount, 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';
|
||||
|
|
@ -37,6 +37,7 @@ export class MastodonApiServerService {
|
|||
private config: Config,
|
||||
private metaService: MetaService,
|
||||
private userEntityService: UserEntityService,
|
||||
private mastoConverter: MastoConverters,
|
||||
) { }
|
||||
|
||||
@bindThis
|
||||
|
|
@ -236,7 +237,7 @@ export class MastodonApiServerService {
|
|||
const client = getClient(BASE_URL, accessTokens); // we are using this here, because in private mode some info isnt
|
||||
// displayed without being logged in
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.verifyCredentials());
|
||||
} catch (e: any) {
|
||||
/* console.error(e); */
|
||||
|
|
@ -286,7 +287,7 @@ export class MastodonApiServerService {
|
|||
ids = [ids];
|
||||
}
|
||||
users = ids;
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.getRelationships(users));
|
||||
} catch (e: any) {
|
||||
/* console.error(e); */
|
||||
|
|
@ -319,7 +320,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.getStatuses());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -347,7 +348,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.getFollowers());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -361,7 +362,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.getFollowing());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -389,7 +390,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.addFollow());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -403,7 +404,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.rmFollow());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -417,7 +418,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.addBlock());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -431,7 +432,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.rmBlock());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -445,7 +446,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.addMute());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -459,7 +460,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.rmMute());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -487,7 +488,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.getBookmarks());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -501,7 +502,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.getFavourites());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -515,7 +516,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.getMutes());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -529,7 +530,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.getBlocks());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -557,7 +558,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.acceptFollow());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -571,7 +572,7 @@ export class MastodonApiServerService {
|
|||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const account = new ApiAccountMastodon(_request, client, BASE_URL, this.mastoConverter);
|
||||
reply.send(await account.rejectFollow());
|
||||
} catch (e: any) {
|
||||
/* console.error(e);
|
||||
|
|
@ -756,7 +757,7 @@ export class MastodonApiServerService {
|
|||
//#endregion
|
||||
|
||||
//#region Timelines
|
||||
const TLEndpoint = new ApiTimelineMastodon(fastify, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const TLEndpoint = new ApiTimelineMastodon(fastify, this.config, this.mastoConverter);
|
||||
|
||||
// GET Endpoints
|
||||
TLEndpoint.getTL();
|
||||
|
|
@ -781,7 +782,7 @@ export class MastodonApiServerService {
|
|||
//#endregion
|
||||
|
||||
//#region Status
|
||||
const NoteEndpoint = new ApiStatusMastodon(fastify, this.config, this.usersRepository, this.notesRepository, this.noteEditRepository, this.userEntityService);
|
||||
const NoteEndpoint = new ApiStatusMastodon(fastify, this.mastoConverter);
|
||||
|
||||
// GET Endpoints
|
||||
NoteEndpoint.getStatus();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue