From 7eddd663851a08b4d68f318989ff748dd1a8a030 Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Sun, 23 Apr 2023 08:10:19 -0500 Subject: [PATCH] Support case where post sender is the only author --- forum-network/src/classes/dao/validation-pool.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/forum-network/src/classes/dao/validation-pool.js b/forum-network/src/classes/dao/validation-pool.js index 8300f54..f3cbfa5 100644 --- a/forum-network/src/classes/dao/validation-pool.js +++ b/forum-network/src/classes/dao/validation-pool.js @@ -113,9 +113,11 @@ export class ValidationPool extends ReputationHolder { throw new Error(`Each citation magnitude must not exceed revaluation limit ${params.revaluationLimit}`); } - const totalAuthorWeight = (post.authors ?? []).reduce((total, { weight }) => total += weight, 0); - if (totalAuthorWeight !== 1) { - throw new Error(`Total author weight ${totalAuthorWeight} !== 1`); + if (post.authors?.length) { + const totalAuthorWeight = post.authors.reduce((total, { weight }) => total += weight, 0); + if (totalAuthorWeight !== 1) { + throw new Error(`Total author weight ${totalAuthorWeight} !== 1`); + } } this.state = ValidationPoolStates.OPEN;