mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-25 05:55:14 +00:00
merge: refactor: Use proper logging facilities in WebfingerService (!615)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/615 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
7f849b3502
1 changed files with 7 additions and 1 deletions
|
@ -8,6 +8,8 @@ import { Injectable } from '@nestjs/common';
|
||||||
import { XMLParser } from 'fast-xml-parser';
|
import { XMLParser } from 'fast-xml-parser';
|
||||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import type Logger from '@/logger.js';
|
||||||
|
import { RemoteLoggerService } from './RemoteLoggerService.js';
|
||||||
|
|
||||||
export type ILink = {
|
export type ILink = {
|
||||||
href: string;
|
href: string;
|
||||||
|
@ -28,9 +30,13 @@ const defaultProtocol = process.env.MISSKEY_WEBFINGER_USE_HTTP?.toLowerCase() ==
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WebfingerService {
|
export class WebfingerService {
|
||||||
|
private logger: Logger;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private httpRequestService: HttpRequestService,
|
private httpRequestService: HttpRequestService,
|
||||||
|
private remoteLoggerService: RemoteLoggerService,
|
||||||
) {
|
) {
|
||||||
|
this.logger = this.remoteLoggerService.logger.createSubLogger('webfinger');
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -103,7 +109,7 @@ export class WebfingerService {
|
||||||
const template = (hostMeta['XRD']['Link'] as Array<any>).filter(p => p['@_rel'] === 'lrdd')[0]['@_template'];
|
const template = (hostMeta['XRD']['Link'] as Array<any>).filter(p => p['@_rel'] === 'lrdd')[0]['@_template'];
|
||||||
return template.indexOf('{uri}') < 0 ? null : template;
|
return template.indexOf('{uri}') < 0 ? null : template;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`error while request host-meta for ${url}: ${err}`);
|
this.logger.error(`error while request host-meta for ${url}: ${err}`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue