From 3327277f2a4f9e1e933c334af7280054561f83dc Mon Sep 17 00:00:00 2001 From: benk10 Date: Sun, 17 May 2020 12:19:35 +0300 Subject: [PATCH] Fix IPFS crash (#557) * Fix IPFS crash * Update proposal.ts --- src/domain/proposal.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/domain/proposal.ts b/src/domain/proposal.ts index 6d1c2063..db3ff909 100644 --- a/src/domain/proposal.ts +++ b/src/domain/proposal.ts @@ -74,7 +74,7 @@ export function getProposalIPFSData(proposal: Proposal): Proposal { let tags: string[] = []; let tagsLength = tagsObjects.length < 100 ? tagsObjects.length : 100; for (let i = 0; i < tagsLength; i++) { - if (tags.indexOf(tagsObjects[i].toString()) === -1) { + if (tagsObjects[i].kind === JSONValueKind.STRING && tags.indexOf(tagsObjects[i].toString()) === -1) { tags.push(tagsObjects[i].toString()); let tagEnt = Tag.load(tagsObjects[i].toString()); if (tagEnt == null) { @@ -118,15 +118,19 @@ export function getIPFSData(descHash: string): IPFSData { if (descJson.kind !== JSONValueKind.OBJECT) { return result; } - if (descJson.toObject().get('title') != null) { + if (descJson.toObject().get('title') != null && descJson.toObject().get('title').kind === JSONValueKind.STRING) { result.title = descJson.toObject().get('title').toString(); result.fulltext = result.title.split(' '); } - if (descJson.toObject().get('description') != null) { + if ( + descJson.toObject().get('description') != null && + descJson.toObject().get('description').kind === JSONValueKind.STRING + ) { result.description = descJson.toObject().get('description').toString(); result.fulltext = result.fulltext.concat(result.description.split(' ')); } - if (descJson.toObject().get('url') != null) { + if (descJson.toObject().get('url') != null && + descJson.toObject().get('url').kind === JSONValueKind.STRING) { result.url = descJson.toObject().get('url').toString(); } let tagsData = descJson.toObject().get('tags');