diff --git a/src/queue/processors/inbox.ts b/src/queue/processors/inbox.ts index 1ef31ea64..6447d318e 100644 --- a/src/queue/processors/inbox.ts +++ b/src/queue/processors/inbox.ts @@ -12,6 +12,7 @@ import { registerOrFetchInstanceDoc } from '../../services/register-or-fetch-ins import Instance from '../../models/instance'; import instanceChart from '../../services/chart/instance'; import { validActor } from '../../remote/activitypub/type'; +import { toDbHost } from '../../misc/convert-host'; const logger = new Logger('inbox'); @@ -47,7 +48,7 @@ export default async (job: Bull.Job): Promise => { // ブロックしてたら中断 // TODO: いちいちデータベースにアクセスするのはコスト高そうなのでどっかにキャッシュしておく - const instance = await Instance.findOne({ host: host.toLowerCase() }); + const instance = await Instance.findOne({ host: toDbHost(host) }); if (instance && instance.isBlocked) { logger.info(`Blocked request: ${host}`); return; @@ -66,7 +67,7 @@ export default async (job: Bull.Job): Promise => { // ブロックしてたら中断 // TODO: いちいちデータベースにアクセスするのはコスト高そうなのでどっかにキャッシュしておく - const instance = await Instance.findOne({ host: host.toLowerCase() }); + const instance = await Instance.findOne({ host: toDbHost(host) }); if (instance && instance.isBlocked) { logger.warn(`Blocked request: ${host}`); return; diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index 08dd7a6ba..7fd05f776 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -4,13 +4,13 @@ import { URL } from 'url'; import * as crypto from 'crypto'; import { lookup, IRunOptions } from 'lookup-dns-cache'; import * as promiseAny from 'promise-any'; -import { toUnicode } from 'punycode'; import config from '../../config'; import { ILocalUser } from '../../models/user'; import { publishApLogStream } from '../../services/stream'; import { apLogger } from './logger'; import Instance from '../../models/instance'; +import { toDbHost } from '../../misc/convert-host'; export const logger = apLogger.createSubLogger('deliver'); @@ -23,7 +23,7 @@ export default async (user: ILocalUser, url: string, object: any) => { // ブロックしてたら中断 // TODO: いちいちデータベースにアクセスするのはコスト高そうなのでどっかにキャッシュしておく - const instance = await Instance.findOne({ host: toUnicode(host) }); + const instance = await Instance.findOne({ host: toDbHost(host) }); if (instance && instance.isBlocked) return; const data = JSON.stringify(object);