aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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',