From a4a96710b03934edd96598900b626274cf3b26b9 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sat, 15 Jun 2019 17:09:59 +0900 Subject: [PATCH] =?UTF-8?q?=E9=96=89=E9=8E=96=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=82=8B=E3=83=9B=E3=82=B9=E3=83=88=E3=81=AB=E3=81=AFAP=20deli?= =?UTF-8?q?ver=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=20(#5?= =?UTF-8?q?057)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 閉鎖しているホストにはAP deliverしないように * fix case --- src/remote/activitypub/request.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index 3b69dd9ae..bde4921c3 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -9,7 +9,7 @@ import config from '../../config'; import { ILocalUser } from '../../models/entities/user'; import { publishApLogStream } from '../../services/stream'; import { apLogger } from './logger'; -import { UserKeypairs } from '../../models'; +import { UserKeypairs, Instances } from '../../models'; import { fetchMeta } from '../../misc/fetch-meta'; import { toPuny } from '../../misc/convert-host'; import { ensure } from '../../prelude/ensure'; @@ -17,15 +17,30 @@ import { ensure } from '../../prelude/ensure'; export const logger = apLogger.createSubLogger('deliver'); export default async (user: ILocalUser, url: string, object: any) => { - logger.info(`--> ${url}`); - const timeout = 10 * 1000; const { protocol, host, hostname, port, pathname, search } = new URL(url); // ブロックしてたら中断 const meta = await fetchMeta(); - if (meta.blockedHosts.includes(toPuny(host))) return; + if (meta.blockedHosts.includes(toPuny(host))) { + logger.info(`skip (blocked) ${url}`); + return; + } + + // closedなら中断 + const closedHosts = await Instances.find({ + where: { + isMarkedAsClosed: true + }, + cache: 60 * 1000 + }); + if (closedHosts.map(x => x.host).includes(toPuny(host))) { + logger.info(`skip (closed) ${url}`); + return; + } + + logger.info(`--> ${url}`); const data = JSON.stringify(object);