From d9780606b3f69fc7fff96245c032c2e443dc3432 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 7 Apr 2019 23:06:07 +0900 Subject: [PATCH] Refactor --- src/queue/processors/db/import-following.ts | 2 +- src/queue/processors/db/import-user-lists.ts | 2 +- src/remote/resolve-user.ts | 4 ++-- src/server/api/endpoints/users/show.ts | 6 +++--- src/services/note/create.ts | 2 +- src/tools/resync-remote-user.ts | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/queue/processors/db/import-following.ts b/src/queue/processors/db/import-following.ts index 2e646c1869..07a1639494 100644 --- a/src/queue/processors/db/import-following.ts +++ b/src/queue/processors/db/import-following.ts @@ -3,7 +3,7 @@ import * as Bull from 'bull'; import { queueLogger } from '../../logger'; import follow from '../../../services/following/create'; import parseAcct from '../../../misc/acct/parse'; -import resolveUser from '../../../remote/resolve-user'; +import { resolveUser } from '../../../remote/resolve-user'; import { downloadTextFile } from '../../../misc/download-text-file'; import { isSelfHost, toDbHost } from '../../../misc/convert-host'; import { Users, DriveFiles } from '../../../models'; diff --git a/src/queue/processors/db/import-user-lists.ts b/src/queue/processors/db/import-user-lists.ts index 8be5785896..ff896c1bef 100644 --- a/src/queue/processors/db/import-user-lists.ts +++ b/src/queue/processors/db/import-user-lists.ts @@ -2,7 +2,7 @@ import * as Bull from 'bull'; import { queueLogger } from '../../logger'; import parseAcct from '../../../misc/acct/parse'; -import resolveUser from '../../../remote/resolve-user'; +import { resolveUser } from '../../../remote/resolve-user'; import { pushUserToUserList } from '../../../services/user-list/push'; import { downloadTextFile } from '../../../misc/download-text-file'; import { isSelfHost, toDbHost } from '../../../misc/convert-host'; diff --git a/src/remote/resolve-user.ts b/src/remote/resolve-user.ts index be846ab279..a10d3c2d84 100644 --- a/src/remote/resolve-user.ts +++ b/src/remote/resolve-user.ts @@ -10,7 +10,7 @@ import { Users } from '../models'; const logger = remoteLogger.createSubLogger('resolve-user'); -export default async (username: string, _host: string, option?: any, resync = false): Promise => { +export async function resolveUser(username: string, _host: string, option?: any, resync = false): Promise { const usernameLower = username.toLowerCase(); if (_host == null) { @@ -73,7 +73,7 @@ export default async (username: string, _host: string, option?: any, resync = fa logger.info(`return existing remote user: ${acctLower}`); return user; -}; +} async function resolveSelf(acctLower: string) { logger.info(`WebFinger for ${chalk.yellow(acctLower)}`); diff --git a/src/server/api/endpoints/users/show.ts b/src/server/api/endpoints/users/show.ts index a605eaf30a..ae93e40eaa 100644 --- a/src/server/api/endpoints/users/show.ts +++ b/src/server/api/endpoints/users/show.ts @@ -1,5 +1,5 @@ import $ from 'cafy'; -import resolveRemoteUser from '../../../../remote/resolve-user'; +import { resolveUser } from '../../../../remote/resolve-user'; import define from '../../define'; import { apiLogger } from '../../logger'; import { ApiError } from '../../error'; @@ -75,7 +75,7 @@ export default define(meta, async (ps, me) => { } else { // Lookup user if (typeof ps.host === 'string') { - user = await resolveRemoteUser(ps.username, ps.host).catch(e => { + user = await resolveUser(ps.username, ps.host).catch(e => { apiLogger.warn(`failed to resolve remote user: ${e}`); throw new ApiError(meta.errors.failedToResolveRemoteUser); }); @@ -94,7 +94,7 @@ export default define(meta, async (ps, me) => { // ユーザー情報更新 if (Users.isRemoteUser(user)) { if (user.lastFetchedAt == null || Date.now() - user.lastFetchedAt.getTime() > 1000 * 60 * 60 * 24) { - resolveRemoteUser(ps.username, ps.host, { }, true); + resolveUser(ps.username, ps.host, { }, true); } } diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 9ac9223d3c..305e173e16 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -7,7 +7,7 @@ import renderAnnounce from '../../remote/activitypub/renderer/announce'; import { renderActivity } from '../../remote/activitypub/renderer'; import watch from './watch'; import { parse } from '../../mfm/parse'; -import resolveUser from '../../remote/resolve-user'; +import { resolveUser } from '../../remote/resolve-user'; import config from '../../config'; import { updateHashtag } from '../update-hashtag'; import { erase, concat } from '../../prelude/array'; diff --git a/src/tools/resync-remote-user.ts b/src/tools/resync-remote-user.ts index 7db5fe82ef..52f63cf1f1 100644 --- a/src/tools/resync-remote-user.ts +++ b/src/tools/resync-remote-user.ts @@ -1,5 +1,5 @@ import parseAcct from '../misc/acct/parse'; -import resolveUser from '../remote/resolve-user'; +import { resolveUser } from '../remote/resolve-user'; async function main(acct: string): Promise { const { username, host } = parseAcct(acct);