aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-12-24 12:13:08 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-12-24 12:13:08 -1000
commit079499f482a67c8007cea211c9000eb90aa4e67a (patch)
tree89cb5ae9c571380f47a52cad531b8b86b50e5e36
parente3e377748bf340d5a39d201b17fe4cdbab8733c0 (diff)
downloadpatchfoo-079499f482a67c8007cea211c9000eb90aa4e67a.tar.gz
patchfoo-079499f482a67c8007cea211c9000eb90aa4e67a.zip
Allow previewing votes
-rw-r--r--README.md2
-rw-r--r--lib/app.js1
-rw-r--r--lib/serve.js16
3 files changed, 16 insertions, 3 deletions
diff --git a/README.md b/README.md
index 74a9012..288e229 100644
--- a/README.md
+++ b/README.md
@@ -73,6 +73,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.:
"host": "::",
"filter": "all",
"showPrivates": true,
+ "previewVotes": true,
}
}
```
@@ -89,6 +90,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.:
- `auth`: HTTP auth password. default: `null` (no password required)
- `filter`: Filter setting. `"all"` to show all messages. `"invert"` to show messages that would be hidden by the default setting. Otherwise the default setting applies, which is so to only show messages authored or upvoted by yourself or by a feed that you you follow. Exceptions are that if you navigate to a user feed page, you will see messages authored by that feed, and if you navigate to a message page, you will see that message - regardless of the filter setting. The `filter` setting may also be specified per-request as a query string parameter.
- `showPrivates`: Whether or not to show private messages. Default is `true`. Overridden by `filter=all`.
+- `previewVotes`: Whether to preview creating votes/likes/digs (`true`) or publish them immediately (`false`). default: `false`
## TODO
diff --git a/lib/app.js b/lib/app.js
index 99ba776..4068530 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -31,6 +31,7 @@ function App(sbot, config) {
this.host = conf.host || 'localhost'
this.msgFilter = conf.filter
this.showPrivates = conf.showPrivates == null ? true : conf.showPrivates
+ this.previewVotes = conf.previewVotes == null ? false : conf.previewVotes
var base = conf.base || '/'
this.opts = {
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] = {