From 5c13d7dc8dd9c1117f5e31633ddb3e5858ee474c Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Sun, 16 Apr 2017 21:38:48 +0200 Subject: [PATCH] Better serve channel query, better error handling --- index.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index ebdd2d7..419c47b 100644 --- a/index.js +++ b/index.js @@ -118,7 +118,7 @@ exports.init = function (sbot, config) { } pull( - sbot.createUserStream({ id: feedId, reverse: true, limit: 100 }), + sbot.createUserStream({ id: feedId, reverse: true }), pull.collect(function (err, logs) { if (err) return respond(res, 500, err.stack || err) res.writeHead(200, { @@ -193,7 +193,7 @@ exports.init = function (sbot, config) { } pull( - sbot.createLogStream({ reverse: true, limit: 1000 }), + sbot.createLogStream({ reverse: true, limit: 2500 }), pull.filter((msg) => { return !msg.value || (msg.value.author in following || @@ -220,7 +220,7 @@ exports.init = function (sbot, config) { }) ) } - + function serveChannel(req, res, url) { var channelId = url.substring(url.lastIndexOf('channel/')+8, 100) console.log("serving channel: " + channelId) @@ -241,10 +241,7 @@ exports.init = function (sbot, config) { } pull( - sbot.createLogStream({ reverse: true, limit: 2000 }), - pull.filter((msg) => { - return !msg.value || msg.value.content.channel == channelId - }), + sbot.query.read({ limit: 500, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}), pull.filter((msg) => { // channel subscription return !msg.value.content.subscribed }), @@ -596,8 +593,12 @@ function render(opts, c) linkedText = c.vote.linkedText.substring(0, 100) return ' voted ' + linkedText + '' } - else if (c.type == 'contact' && c.following) - return ' followed ' + c.contactAbout.name + "" + else if (c.type == 'contact' && c.following) { + var name = c.contact + if (typeof c.contactAbout != 'undefined') + name = c.contactAbout.name + return ' followed ' + name + "" + } else if (typeof c == 'string') return ' wrote something private ' else if (c.type == 'about')