Better log

This commit is contained in:
syuilo 2019-02-03 04:43:43 +09:00
parent 2f215ea34c
commit 6071fc7077
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69

View file

@ -5,6 +5,7 @@ import config from '../config';
import { createPerson, updatePerson } from './activitypub/models/person'; import { createPerson, updatePerson } from './activitypub/models/person';
import { URL } from 'url'; import { URL } from 'url';
import { remoteLogger } from './logger'; import { remoteLogger } from './logger';
import chalk from 'chalk';
const logger = remoteLogger.createSubLogger('resolve-user'); const logger = remoteLogger.createSubLogger('resolve-user');
@ -34,7 +35,7 @@ export default async (username: string, _host: string, option?: any, resync?: bo
if (user === null) { if (user === null) {
const self = await resolveSelf(acctLower); const self = await resolveSelf(acctLower);
logger.info(`return new remote user: ${acctLower}`); logger.succ(`return new remote user: ${chalk.magenta(acctLower)}`);
return await createPerson(self.href); return await createPerson(self.href);
} }
@ -76,7 +77,7 @@ logger.info(`return existing remote user: ${acctLower}`);
}; };
async function resolveSelf(acctLower: string) { async function resolveSelf(acctLower: string) {
logger.info(`WebFinger for ${acctLower}`); logger.info(`WebFinger for ${chalk.yellow(acctLower)}`);
const finger = await webFinger(acctLower); const finger = await webFinger(acctLower);
const self = finger.links.find(link => link.rel && link.rel.toLowerCase() === 'self'); const self = finger.links.find(link => link.rel && link.rel.toLowerCase() === 'self');
if (!self) { if (!self) {