apResolverのUndiciFetcherを廃止しapRequestのものを使う、 add ap logger

This commit is contained in:
tamaina 2023-01-11 15:59:43 +00:00
parent 15014e3aaf
commit 997243915c
2 changed files with 5 additions and 9 deletions

View file

@ -6,6 +6,7 @@ import type { Config } from '@/config.js';
import type { User } from '@/models/entities/User.js';
import { UserKeypairStoreService } from '@/core/UserKeypairStoreService.js';
import { HttpRequestService, UndiciFetcher } from '@/core/HttpRequestService.js';
import { LoggerService } from '@/core/LoggerService.js';
import { bindThis } from '@/decorators.js';
type Request = {
@ -28,7 +29,7 @@ type PrivateKey = {
@Injectable()
export class ApRequestService {
private undiciFetcher: UndiciFetcher;
public undiciFetcher: UndiciFetcher;
constructor(
@Inject(DI.config)
@ -36,10 +37,11 @@ export class ApRequestService {
private userKeypairStoreService: UserKeypairStoreService,
private httpRequestService: HttpRequestService,
private loggerService: LoggerService,
) {
this.undiciFetcher = new UndiciFetcher(this.httpRequestService.getStandardUndiciFetcherOption({
maxRedirections: 0,
}));
}), this.loggerService.getLogger('ap-request'));
}
@bindThis

View file

@ -4,7 +4,6 @@ import { InstanceActorService } from '@/core/InstanceActorService.js';
import type { NotesRepository, PollsRepository, NoteReactionsRepository, UsersRepository } from '@/models/index.js';
import type { Config } from '@/config.js';
import { MetaService } from '@/core/MetaService.js';
import { HttpRequestService, UndiciFetcher } from '@/core/HttpRequestService.js';
import { DI } from '@/di-symbols.js';
import { UtilityService } from '@/core/UtilityService.js';
import { bindThis } from '@/decorators.js';
@ -17,7 +16,6 @@ import type { IObject, ICollection, IOrderedCollection } from './type.js';
export class Resolver {
private history: Set<string>;
private user?: ILocalUser;
private undiciFetcher: UndiciFetcher;
constructor(
private config: Config,
@ -29,15 +27,11 @@ export class Resolver {
private instanceActorService: InstanceActorService,
private metaService: MetaService,
private apRequestService: ApRequestService,
private httpRequestService: HttpRequestService,
private apRendererService: ApRendererService,
private apDbResolverService: ApDbResolverService,
private recursionLimit = 100,
) {
this.history = new Set();
this.undiciFetcher = new UndiciFetcher(this.httpRequestService.getStandardUndiciFetcherOption({
maxRedirections: 0,
}));
}
@bindThis
@ -101,7 +95,7 @@ export class Resolver {
const object = (this.user
? await this.apRequestService.signedGet(value, this.user) as IObject
: await this.undiciFetcher.getJson<IObject>(value, 'application/activity+json, application/ld+json'));
: await this.apRequestService.undiciFetcher.getJson<IObject>(value, 'application/activity+json, application/ld+json'));
if (object == null || (
Array.isArray(object['@context']) ?