aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-05-10 12:44:20 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-05-10 18:31:03 -1000
commit17233e4ef8a6f672b84a5ac786dc90a8e4a530a1 (patch)
tree59724c1054933411d58488c7971b80e536ce21c2 /lib/serve.js
parentb43e57849f5f07ba972639c8be10586da74e474c (diff)
downloadpatchfoo-17233e4ef8a6f672b84a5ac786dc90a8e4a530a1.tar.gz
patchfoo-17233e4ef8a6f672b84a5ac786dc90a8e4a530a1.zip
Default to publish votes without branch/root.
Don't include vote messages in post branch links by default.
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js11
1 files changed, 7 insertions, 4 deletions
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,
})