summaryrefslogtreecommitdiff
path: root/src/remote/activitypub
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2019-11-07 00:02:18 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-11-07 00:02:18 +0900
commit873444c3c6f7e3b9ecb6cce569d8cdb3fa032012 (patch)
tree30a52b7ac3025e92c0e9ce5c7028a96af83f7088 /src/remote/activitypub
parentResolve #5582 (#5583) (diff)
downloadsharkey-873444c3c6f7e3b9ecb6cce569d8cdb3fa032012.tar.gz
sharkey-873444c3c6f7e3b9ecb6cce569d8cdb3fa032012.tar.bz2
sharkey-873444c3c6f7e3b9ecb6cce569d8cdb3fa032012.zip
APの統計とログの修正と強化 (#5585)
* Fix #5580 * Improve AP logging
Diffstat (limited to 'src/remote/activitypub')
-rw-r--r--src/remote/activitypub/request.ts32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts
index a48bc1e3f3..e4f3018336 100644
--- a/src/remote/activitypub/request.ts
+++ b/src/remote/activitypub/request.ts
@@ -6,15 +6,10 @@ import * as cache from 'lookup-dns-cache';
import config from '../../config';
import { ILocalUser } from '../../models/entities/user';
import { publishApLogStream } from '../../services/stream';
-import { apLogger } from './logger';
-import { UserKeypairs, Instances } from '../../models';
-import { fetchMeta } from '../../misc/fetch-meta';
-import { toPuny } from '../../misc/convert-host';
+import { UserKeypairs } from '../../models';
import { ensure } from '../../prelude/ensure';
import * as httpsProxyAgent from 'https-proxy-agent';
-export const logger = apLogger.createSubLogger('deliver');
-
const agent = config.proxy
? new httpsProxyAgent(config.proxy)
: new https.Agent({
@@ -24,28 +19,7 @@ const agent = config.proxy
export default async (user: ILocalUser, url: string, object: any) => {
const timeout = 10 * 1000;
- const { protocol, host, hostname, port, pathname, search } = new URL(url);
-
- // ブロックしてたら中断
- const meta = await fetchMeta();
- 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 { protocol, hostname, port, pathname, search } = new URL(url);
const data = JSON.stringify(object);
@@ -73,10 +47,8 @@ export default async (user: ILocalUser, url: string, object: any) => {
}
}, res => {
if (res.statusCode! >= 400) {
- logger.warn(`${url} --> ${res.statusCode}`);
reject(res);
} else {
- logger.succ(`${url} --> ${res.statusCode}`);
resolve();
}
});