From 2615368b1e16571024708782ddddbac5f1a116b1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 15 Jun 2019 00:07:41 +0900 Subject: Resolve #365 --- src/remote/activitypub/models/person.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/remote') diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index 654d36403e..dcd64e0cd7 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -53,12 +53,14 @@ function validatePerson(x: any, uri: string) { return new Error('invalid person: inbox is not a string'); } - if (!Users.validateUsername(x.preferredUsername, true)) { + if (!Users.validateRemoteUsername.ok(x.preferredUsername)) { return new Error('invalid person: invalid username'); } - if (!Users.isValidName(x.name == '' ? null : x.name)) { - return new Error('invalid person: invalid name'); + if (x.name != null && x.name != '') { + if (!Users.validateName.ok(x.name)) { + return new Error('invalid person: invalid name'); + } } if (typeof x.id !== 'string') { -- cgit v1.2.3-freya 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: 閉鎖しているホストにはAP deliverしないように (#5057) 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(-) (limited to 'src/remote') diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index 3b69dd9ae4..bde4921c3a 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); -- cgit v1.2.3-freya