aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-07 19:47:47 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-09 19:44:36 -1000
commit8a7b661c6e85a7abf568132effac4b68ffe51a6a (patch)
tree7622839ad6a40508969e09b47d5b126c8b6406aa
parentf13fbed3ce0247e55561b3dbe35819c672958cd7 (diff)
downloadpatchfoo-8a7b661c6e85a7abf568132effac4b68ffe51a6a.tar.gz
patchfoo-8a7b661c6e85a7abf568132effac4b68ffe51a6a.zip
Redirect to published message from /compose
-rw-r--r--lib/serve.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 8e63ff5..defac87 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -132,10 +132,17 @@ Serve.prototype.go = function () {
else next()
}
- function next(err) {
+ function next(err, publishedMsg) {
if (err) {
self.res.writeHead(400, {'Content-Type': 'text/plain'})
self.res.end(err.stack)
+ } else if (publishedMsg) {
+ if (self.data.redirect_to_published_msg) {
+ self.redirect(self.app.render.toUrl(publishedMsg.key))
+ } else {
+ self.publishedMsg = publishedMsg
+ self.handle()
+ }
} else {
self.handle()
}
@@ -188,8 +195,7 @@ Serve.prototype.publish = function (content, cb) {
if (err) return cb(err)
delete self.data.text
delete self.data.recps
- self.publishedMsg = msg
- return cb()
+ return cb(null, msg)
})
})
}
@@ -477,6 +483,7 @@ Serve.prototype.compose = function (ext) {
var self = this
self.composer({
channel: '',
+ redirectToPublishedMsg: true,
}, function (err, composer) {
if (err) return cb(err)
pull(
@@ -1472,6 +1479,8 @@ Serve.prototype.composer = function (opts, cb) {
return [
h('input', {type: 'hidden', name: 'content',
value: JSON.stringify(content)}),
+ opts.redirectToPublishedMsg ? h('input', {type: 'hidden',
+ name: 'redirect_to_published_msg', value: '1'}) : '',
h('div', h('em', 'draft:')),
msgContainer,
h('div.composer-actions',