Support case where post sender is the only author

This commit is contained in:
Ladd Hoffman 2023-04-23 08:10:19 -05:00
parent 21a0ef6bda
commit 7eddd66385
1 changed files with 5 additions and 3 deletions

View File

@ -113,9 +113,11 @@ export class ValidationPool extends ReputationHolder {
throw new Error(`Each citation magnitude must not exceed revaluation limit ${params.revaluationLimit}`); throw new Error(`Each citation magnitude must not exceed revaluation limit ${params.revaluationLimit}`);
} }
const totalAuthorWeight = (post.authors ?? []).reduce((total, { weight }) => total += weight, 0); if (post.authors?.length) {
if (totalAuthorWeight !== 1) { const totalAuthorWeight = post.authors.reduce((total, { weight }) => total += weight, 0);
throw new Error(`Total author weight ${totalAuthorWeight} !== 1`); if (totalAuthorWeight !== 1) {
throw new Error(`Total author weight ${totalAuthorWeight} !== 1`);
}
} }
this.state = ValidationPoolStates.OPEN; this.state = ValidationPoolStates.OPEN;