aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/app.js1
-rw-r--r--lib/serve.js11
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/app.js b/lib/app.js
index 9da761e..621f557 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -53,6 +53,7 @@ function App(sbot, config) {
|| new Buffer('pmr+IzM+4VAZgi5H5bOopXkwnzqrNussS7DtAJsfbf0=', 'base64')
// sha256('peer-invites:DEVELOPMENT')
*/
+ this.voteBranches = !!config.voteBranches
this.hostname = (/:/.test(this.host) ? '[' + this.host + ']' : this.host) + this.port
this.dir = path.join(config.path, conf.dir || 'patchfoo')
diff --git a/lib/serve.js b/lib/serve.js
index d8be4fc..ed8b20d 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -1297,12 +1297,14 @@ Serve.prototype.channel = function (path) {
)
}
-function threadHeads(msgs, rootId) {
+function threadHeads(msgs, rootId, opts) {
+ var includeVotes = opts && opts.includeVotes
return sort.heads(msgs.filter(function (msg) {
var c = msg.value && msg.value.content
return (c && (
c.type === 'web-root' ? c.site === rootId :
c.type === 'talenet-idea-comment_reply' ? c.ideaKey === rootId :
+ c.type === 'vote' ? includeVotes :
c.root === rootId))
|| msg.key === rootId
}))
@@ -1311,6 +1313,7 @@ function threadHeads(msgs, rootId) {
Serve.prototype.streamThreadWithComposer = function (opts) {
var self = this
var id = opts.root
+ var threadHeadsOpts = {includeVotes: self.app.voteBranches}
return ph('table', {class: 'ssb-msgs'}, u.readNext(next))
function next(cb) {
self.getMsgDecryptedMaybeOoo(id, function (err, rootMsg) {
@@ -1346,10 +1349,10 @@ Serve.prototype.streamThreadWithComposer = function (opts) {
)
function gotLinks(err, links) {
if (err) return cb(new Error(err.stack))
- var branches = threadHeads(links, threadRootId)
+ var branches = threadHeads(links, threadRootId, threadHeadsOpts)
cb(null, pull(
pull.values(sort(links)),
- pull.map(function (link) {
+ self.app.voteBranches && pull.map(function (link) {
var o = {}
for (var k in link) o[k] = link[k]
o.threadBranches = branches
@@ -1366,7 +1369,7 @@ Serve.prototype.streamThreadWithComposer = function (opts) {
root: threadRootId,
post: id,
branches: branches,
- postBranches: threadRootId !== id && threadHeads(links, id),
+ postBranches: threadRootId !== id && threadHeads(links, id, threadHeadsOpts),
placeholder: opts.placeholder,
channel: channel,
})