Commit 5c13d7dc8dd9c1117f5e31633ddb3e5858ee474c
Better serve channel query, better error handling
Anders Rune Jensen committed on 4/16/2017, 7:38:48 PMParent: 7a12c1f494b0b6574d5a0d55d80323291a5b5c20
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -117,9 +117,9 @@ | ||
117 | 117 … | renderer: new MdRenderer(opts) |
118 | 118 … | } |
119 | 119 … | |
120 | 120 … | pull( |
121 | - sbot.createUserStream({ id: feedId, reverse: true, limit: 100 }), | |
121 … | + sbot.createUserStream({ id: feedId, reverse: true }), | |
122 | 122 … | pull.collect(function (err, logs) { |
123 | 123 … | if (err) return respond(res, 500, err.stack || err) |
124 | 124 … | res.writeHead(200, { |
125 | 125 … | 'Content-Type': ctype("html") |
@@ -192,9 +192,9 @@ | ||
192 | 192 … | renderer: new MdRenderer(opts) |
193 | 193 … | } |
194 | 194 … | |
195 | 195 … | pull( |
196 | - sbot.createLogStream({ reverse: true, limit: 1000 }), | |
196 … | + sbot.createLogStream({ reverse: true, limit: 2500 }), | |
197 | 197 … | pull.filter((msg) => { |
198 | 198 … | return !msg.value || |
199 | 199 … | (msg.value.author in following || |
200 | 200 … | msg.value.content.channel in channelSubscriptions) |
@@ -219,9 +219,9 @@ | ||
219 | 219 … | ) |
220 | 220 … | }) |
221 | 221 … | ) |
222 | 222 … | } |
223 | - | |
223 … | + | |
224 | 224 … | function serveChannel(req, res, url) { |
225 | 225 … | var channelId = url.substring(url.lastIndexOf('channel/')+8, 100) |
226 | 226 … | console.log("serving channel: " + channelId) |
227 | 227 … | |
@@ -240,12 +240,9 @@ | ||
240 | 240 … | renderer: new MdRenderer(opts) |
241 | 241 … | } |
242 | 242 … | |
243 | 243 … | pull( |
244 | - sbot.createLogStream({ reverse: true, limit: 2000 }), | |
245 | - pull.filter((msg) => { | |
246 | - return !msg.value || msg.value.content.channel == channelId | |
247 | - }), | |
244 … | + sbot.query.read({ limit: 500, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}), | |
248 | 245 … | pull.filter((msg) => { // channel subscription |
249 | 246 … | return !msg.value.content.subscribed |
250 | 247 … | }), |
251 | 248 … | pull.collect(function (err, logs) { |
@@ -595,10 +592,14 @@ | ||
595 | 592 … | if (typeof c.vote.linkedText != 'undefined') |
596 | 593 … | linkedText = c.vote.linkedText.substring(0, 100) |
597 | 594 … | return ' voted <a href="/' + c.vote.link + '">' + linkedText + '</a>' |
598 | 595 … | } |
599 | - else if (c.type == 'contact' && c.following) | |
600 | - return ' followed <a href="/user/' + c.contact + '">' + c.contactAbout.name + "</a>" | |
596 … | + else if (c.type == 'contact' && c.following) { | |
597 … | + var name = c.contact | |
598 … | + if (typeof c.contactAbout != 'undefined') | |
599 … | + name = c.contactAbout.name | |
600 … | + return ' followed <a href="/user/' + c.contact + '">' + name + "</a>" | |
601 … | + } | |
601 | 602 … | else if (typeof c == 'string') |
602 | 603 … | return ' wrote something private ' |
603 | 604 … | else if (c.type == 'about') |
604 | 605 … | return ' changed something in about' |
Built with git-ssb-web