From 079499f482a67c8007cea211c9000eb90aa4e67a Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 24 Dec 2017 12:13:08 -1000 Subject: Allow previewing votes --- lib/serve.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/serve.js') diff --git a/lib/serve.js b/lib/serve.js index c9794a2..40f92a8 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -175,18 +175,25 @@ Serve.prototype.publishJSON = function (cb) { this.publish(content, cb) } -Serve.prototype.publishVote = function (cb) { +Serve.prototype.publishVote = function () { var content = { type: 'vote', channel: this.data.channel || undefined, vote: { link: this.data.link, value: Number(this.data.vote_value), - expression: this.data.vote_expression, + expression: this.data.vote_expression || undefined, } } if (this.data.recps) content.recps = this.data.recps.split(',') - this.publish(content, cb) + if (this.app.previewVotes) { + 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) + } else { + this.publish(content, cb) + } } Serve.prototype.publishContact = function (cb) { @@ -2426,6 +2433,9 @@ Serve.prototype.composer = function (opts, cb) { var data = self.data var myId = self.app.sbot.id + if (!data.text && self.query.text) data.text = self.query.text + if (!data.action && self.query.action) data.action = self.query.action + var blobs = u.tryDecodeJSON(data.blobs) || {} if (data.upload && typeof data.upload === 'object') { blobs[data.upload.link] = { -- cgit v1.2.3