From 18b4f74cdb3f4a0c69855f1ab5b2f286984f1b13 Mon Sep 17 00:00:00 2001 From: mei23 Date: Fri, 31 Aug 2018 16:46:24 +0900 Subject: [PATCH] Improve validation error message --- src/queue/processors/http/process-inbox.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/queue/processors/http/process-inbox.ts b/src/queue/processors/http/process-inbox.ts index a30efe1a3..7e564dd32 100644 --- a/src/queue/processors/http/process-inbox.ts +++ b/src/queue/processors/http/process-inbox.ts @@ -38,7 +38,7 @@ export default async (job: bq.Job, done: any): Promise => { try { ValidateActivity(activity, host); } catch (e) { - console.warn(e); + console.warn(e.message); done(); return; } @@ -55,7 +55,7 @@ export default async (job: bq.Job, done: any): Promise => { try { ValidateActivity(activity, host); } catch (e) { - console.warn(e); + console.warn(e.message); done(); return; } @@ -100,7 +100,10 @@ function ValidateActivity(activity: any, host: string) { // id (if exists) if (typeof activity.id === 'string') { const uriHost = toUnicode(new URL(activity.id).hostname.toLowerCase()); - if (host !== uriHost) throw new Error('activity.id has different host'); + if (host !== uriHost) { + const diag = activity.signature ? '. Has LD-Signature. Forwarded?' : ''; + throw new Error(`activity.id(${activity.id}) has different host(${host})${diag}`); + } } // actor (if exists)