aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-04-29 20:52:20 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-04-29 20:59:37 -1000
commit0cd677474be505a645696c9364d74c8662aeea2b (patch)
tree170d0f88e48b53d0ef3772fdb4e387e05c2c2203 /lib/serve.js
parenta448b261d6bffa420d1f0c4d57ebe852146001bf (diff)
downloadpatchfoo-0cd677474be505a645696c9364d74c8662aeea2b.tar.gz
patchfoo-0cd677474be505a645696c9364d74c8662aeea2b.zip
Render poll messages
Reference message: %N32nKJ79k1G14lfdtr+4o+c1ftjfW22QChiQmR0oP18=.sha256 &2QHE6nnsg2i9JnFmCLq5fExlPwljCyYQYbfxQMXhONs=.sha256
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/serve.js b/lib/serve.js
index e50caa8..7045b30 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -153,6 +153,7 @@ Serve.prototype.go = function () {
else if (data.action === 'publish') self.publishJSON(next)
else if (data.action === 'contact') self.publishContact(next)
else if (data.action === 'want-blobs') self.wantBlobs(next)
+ else if (data.action === 'poll-position') self.publishPollPosition(next)
else if (data.action_vote) self.publishVote(next)
else if (data.action_attend) self.publishAttend(next)
else next()
@@ -225,6 +226,25 @@ Serve.prototype.publishContact = function (next) {
}
}
+Serve.prototype.publishPollPosition = function (cb) {
+ var content = {
+ type: 'position',
+ version: 'v1',
+ channel: this.data.channel || undefined,
+ root: this.data.poll_root,
+ details: {
+ type: this.data.poll_type,
+ choice: this.data.poll_choice
+ }
+ }
+ if (this.data.recps) content.recps = this.data.recps.split(',')
+ var json = JSON.stringify(content, 0, 2)
+ var q = qs.stringify({text: json, action: 'preview'})
+ var url = this.app.render.toUrl('/compose?' + q)
+ this.redirect(url)
+ // this.publish(content, cb)
+}
+
Serve.prototype.publishAttend = function (cb) {
var content = {
type: 'about',