aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-07-27 10:59:40 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-07-27 11:08:30 -1000
commit4f86d04add9a78d06f582d0129f07027154e1d6a (patch)
treea75de1913ffa81e584dfef301105471413c562ec
parentcab781470c10d358f770475c7b25d87e29f614bb (diff)
downloadpatchfoo-4f86d04add9a78d06f582d0129f07027154e1d6a.tar.gz
patchfoo-4f86d04add9a78d06f582d0129f07027154e1d6a.zip
Publish conformant poll-position messages
-rw-r--r--lib/render-msg.js5
-rw-r--r--lib/serve.js10
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index d21f095..2e20d2f 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -1790,6 +1790,11 @@ RenderMsg.prototype.poll = function (cb) {
h('p', 'reason: ',
h('div', h('textarea', {name: 'poll_reason'}))
),
+ u.toArray(this.opts.branches).filter(function (branch) {
+ return branch !== self.msg.key
+ }).map(function (branch) {
+ return h('input', {type: 'hidden', name: 'branches', value: branch})
+ }),
h('p', h('input', {type: 'submit', value: 'preview publish position'}))
) : h('div', 'unknown poll type')
), cb)
diff --git a/lib/serve.js b/lib/serve.js
index b0e1267..db30896 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -232,10 +232,11 @@ Serve.prototype.publishPollPosition = function (cb) {
version: 'v1',
channel: this.data.channel || undefined,
root: this.data.poll_root,
- reason: this.data.poll_reason,
+ branch: this.data.branches || [],
+ reason: this.data.poll_reason || undefined,
details: {
type: this.data.poll_type,
- choice: this.data.poll_choice
+ choice: Number(this.data.poll_choice)
}
}
if (this.data.recps) content.recps = this.data.recps.split(',')
@@ -1100,17 +1101,19 @@ Serve.prototype.streamThreadWithComposer = function (opts) {
)
function gotLinks(err, links) {
if (err) return cb(new Error(err.stack))
+ var branches = threadHeads(links, threadRootId)
cb(null, pull(
pull.values(sort(links)),
self.renderThread({
msgId: id,
+ branches: branches,
}),
self.wrapMessages(),
self.wrapThread({
recps: recps,
root: threadRootId,
post: id,
- branches: threadHeads(links, threadRootId),
+ branches: branches,
postBranches: threadRootId !== id && threadHeads(links, id),
placeholder: opts.placeholder,
channel: channel,
@@ -1339,6 +1342,7 @@ Serve.prototype.renderThread = function (opts) {
filter: this.query.filter,
limit: Number(this.query.limit),
serve: this,
+ branches: opts && opts.branches,
}),
pull.map(u.toHTML)
)