aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-09 13:17:09 -0800
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-09 13:17:09 -0800
commit782eb376f0c664862a849a279cd00967200833f9 (patch)
tree7f4e7d113a0f3ea3809b77c56da18ff41fe01ed9 /lib
parent07d1f78debbe5e7e89a81d0b3c7300e950976ed2 (diff)
downloadpatchfoo-782eb376f0c664862a849a279cd00967200833f9.tar.gz
patchfoo-782eb376f0c664862a849a279cd00967200833f9.zip
robustness
Diffstat (limited to 'lib')
-rw-r--r--lib/serve.js10
1 files changed, 6 insertions, 4 deletions
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})]),