From 17233e4ef8a6f672b84a5ac786dc90a8e4a530a1 Mon Sep 17 00:00:00 2001 From: cel Date: Fri, 10 May 2019 12:44:20 -1000 Subject: Default to publish votes without branch/root. Don't include vote messages in post branch links by default. --- lib/app.js | 1 + lib/serve.js | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') 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, }) -- cgit v1.2.3