git ssb

9+

cel / ssb-viewer



Commit 5c13d7dc8dd9c1117f5e31633ddb3e5858ee474c

Better serve channel query, better error handling

Anders Rune Jensen committed on 4/16/2017, 7:38:48 PM
Parent: 7a12c1f494b0b6574d5a0d55d80323291a5b5c20

Files changed

index.jschanged
index.jsView
@@ -117,9 +117,9 @@
117117 renderer: new MdRenderer(opts)
118118 }
119119
120120 pull(
121- sbot.createUserStream({ id: feedId, reverse: true, limit: 100 }),
121 + sbot.createUserStream({ id: feedId, reverse: true }),
122122 pull.collect(function (err, logs) {
123123 if (err) return respond(res, 500, err.stack || err)
124124 res.writeHead(200, {
125125 'Content-Type': ctype("html")
@@ -192,9 +192,9 @@
192192 renderer: new MdRenderer(opts)
193193 }
194194
195195 pull(
196- sbot.createLogStream({ reverse: true, limit: 1000 }),
196 + sbot.createLogStream({ reverse: true, limit: 2500 }),
197197 pull.filter((msg) => {
198198 return !msg.value ||
199199 (msg.value.author in following ||
200200 msg.value.content.channel in channelSubscriptions)
@@ -219,9 +219,9 @@
219219 )
220220 })
221221 )
222222 }
223-
223 +
224224 function serveChannel(req, res, url) {
225225 var channelId = url.substring(url.lastIndexOf('channel/')+8, 100)
226226 console.log("serving channel: " + channelId)
227227
@@ -240,12 +240,9 @@
240240 renderer: new MdRenderer(opts)
241241 }
242242
243243 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 }}}}]}),
248245 pull.filter((msg) => { // channel subscription
249246 return !msg.value.content.subscribed
250247 }),
251248 pull.collect(function (err, logs) {
@@ -595,10 +592,14 @@
595592 if (typeof c.vote.linkedText != 'undefined')
596593 linkedText = c.vote.linkedText.substring(0, 100)
597594 return ' voted <a href="/' + c.vote.link + '">' + linkedText + '</a>'
598595 }
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 + }
601602 else if (typeof c == 'string')
602603 return ' wrote something private '
603604 else if (c.type == 'about')
604605 return ' changed something in about'

Built with git-ssb-web