From 782eb376f0c664862a849a279cd00967200833f9 Mon Sep 17 00:00:00 2001 From: cel Date: Thu, 9 Feb 2017 13:17:09 -0800 Subject: robustness --- lib/serve.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/serve.js b/lib/serve.js index 9809696..30bcf68 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -352,7 +352,8 @@ Serve.prototype.channel = function (channel) { function threadHeads(msgs, rootId) { return sort.heads(msgs.filter(function (msg) { - return msg.value.content.root === rootId + var c = msg.value.content + return (c && c.root === rootId) || msg.key === rootId })) } @@ -363,10 +364,11 @@ Serve.prototype.id = function (id, ext) { if (self.query.raw != null) return self.rawId(id) this.app.getMsgDecrypted(id, function (err, rootMsg) { + var rootContent = rootMsg && rootMsg.value.content var getRoot = err ? pull.error(err) : pull.once(rootMsg) - var recps = rootMsg && rootMsg.value.content.recps - var threadRootId = rootMsg && rootMsg.value.content.root || id - var channel = rootMsg && rootMsg.value.content.channel + var recps = rootContent && rootContent.recps + var threadRootId = rootContent && rootContent.root || id + var channel = rootContent && rootContent.channel pull( cat([getRoot, self.app.sbot.links({dest: id, values: true})]), -- cgit v1.2.3