aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-01-03 18:25:42 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-01-04 08:42:53 -1000
commit240833027314bd38f229bf5f70a92963378c2117 (patch)
treec107459a0d1096ec1c5900cfef6e5bf370e1bf04
parent0f2d21603df91e7285c4a50da9d9dadf95f600b6 (diff)
downloadpatchfoo-240833027314bd38f229bf5f70a92963378c2117.tar.gz
patchfoo-240833027314bd38f229bf5f70a92963378c2117.zip
Add previewContacts option
Allow previewing a contact messages before publishing it
-rw-r--r--README.md1
-rw-r--r--lib/app.js1
-rw-r--r--lib/serve.js11
3 files changed, 11 insertions, 2 deletions
diff --git a/README.md b/README.md
index 6d59e18..66e95cd 100644
--- a/README.md
+++ b/README.md
@@ -92,6 +92,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.:
- `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`
+- `previewContacts`: Whether to preview creating contact/(un)follow/block messages (`true`) or publish them immediately (`false`). default: `false`
- `ooo`: if true, use `ssb-ooo` to try to fetch missing messages in threads. also can set per-request with query string `?ooo=1`. default: `false`
## TODO
diff --git a/lib/app.js b/lib/app.js
index 2606067..f3b1774 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -32,6 +32,7 @@ function App(sbot, config) {
this.msgFilter = conf.filter
this.showPrivates = conf.showPrivates == null ? true : conf.showPrivates
this.previewVotes = conf.previewVotes == null ? false : conf.previewVotes
+ this.previewContacts = conf.previewContacts == null ? false : conf.previewContacts
this.useOoo = conf.ooo == null ? false : conf.ooo
var base = conf.base || '/'
diff --git a/lib/serve.js b/lib/serve.js
index abf15c3..7c42d0c 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -197,7 +197,7 @@ Serve.prototype.publishVote = function (next) {
}
}
-Serve.prototype.publishContact = function (cb) {
+Serve.prototype.publishContact = function (next) {
var content = {
type: 'contact',
contact: this.data.contact,
@@ -206,7 +206,14 @@ Serve.prototype.publishContact = function (cb) {
if (this.data.block) content.blocking = true
if (this.data.unfollow) content.following = false
if (this.data.unblock) content.blocking = false
- this.publish(content, cb)
+ if (this.app.previewContacts) {
+ 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, next)
+ }
}
Serve.prototype.publishAttend = function (cb) {