1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-02 08:48:32 +09:00

Improve validation error message

This commit is contained in:
mei23 2018-08-31 16:46:24 +09:00
parent e53dde385c
commit 18b4f74cdb

View File

@ -38,7 +38,7 @@ export default async (job: bq.Job, done: any): Promise<void> => {
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<void> => {
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)