aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-03-13 14:15:36 -0400
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-03-13 22:11:10 -0400
commit34982291bc2e6ecdd54fcc74d09d16f6e0929db0 (patch)
tree6744ea7b6f8c295c937ca37e7e85c483ebec752c /lib/serve.js
parent8804ea0353ffbfb5bc6fa82031d8eadfad6ce41a (diff)
downloadpatchfoo-34982291bc2e6ecdd54fcc74d09d16f6e0929db0.tar.gz
patchfoo-34982291bc2e6ecdd54fcc74d09d16f6e0929db0.zip
render missing thread root
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 504c633..62aa86f 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -395,7 +395,7 @@ Serve.prototype.channel = function (channel) {
function threadHeads(msgs, rootId) {
return sort.heads(msgs.filter(function (msg) {
- var c = msg.value.content
+ var c = msg.value && msg.value.content
return (c && c.root === rootId)
|| msg.key === rootId
}))
@@ -407,14 +407,15 @@ 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)
+ if (err && err.name === 'NotFoundError') err = null, rootMsg = {key: id}
+ if (err) return self.respond(500, err.stack || err)
+ var rootContent = rootMsg && rootMsg.value && rootMsg.value.content
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})]),
+ cat([pull.once(rootMsg), self.app.sbot.links({dest: id, values: true})]),
pull.unique('key'),
paramap(self.app.unboxMsg, 4),
pull.collect(function (err, links) {