diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-08-22 17:52:51 -0700 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-08-22 19:10:39 -0700 |
commit | 24765da30eaa84bc6084932ad4b80e8fa73b7521 (patch) | |
tree | 85d7b2ec81b90ddae798c123b2c3c4e75d831b82 | |
parent | 261ac3486383d31a1622bcdcbc2001eb5d790f88 (diff) | |
download | patchfoo-24765da30eaa84bc6084932ad4b80e8fa73b7521.tar.gz patchfoo-24765da30eaa84bc6084932ad4b80e8fa73b7521.zip |
Use Post/Redirect/Get for all message publishing
Fix %1/jp2WMT0l7l+u6yvn1axK5WqkfoQlSuuZkvWlvVEyE=.sha256
-rw-r--r-- | lib/render.js | 6 | ||||
-rw-r--r-- | lib/serve.js | 11 |
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/render.js b/lib/render.js index ec62b31..e246923 100644 --- a/lib/render.js +++ b/lib/render.js @@ -355,11 +355,11 @@ Render.prototype.privateLine = function (recps, isAuthorRecp, cb) { return el } -Render.prototype.msgLink = function (msg, cb) { +Render.prototype.msgIdLink = function (id, cb) { var self = this var el = h('span') - var a = h('a', {href: self.toUrl(msg.key)}, msg.key) - self.app.unboxMsg(msg, function (err, msg) { + var a = h('a', {href: self.toUrl(id)}, id) + self.app.getMsgDecrypted(id, function (err, msg) { if (err) return el.appendChild(u.renderError(err)), cb() var renderMsg = new RenderMsg(self, self.app, msg, {wrap: false}) renderMsg.title(function (err, title) { diff --git a/lib/serve.js b/lib/serve.js index d0a9624..34861bc 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -26,6 +26,7 @@ var Diff = require('diff') var split = require('pull-split') var utf8 = require('pull-utf8-decoder') var webresolve = require('ssb-web-resolver') +var Url = require('url') module.exports = Serve @@ -181,8 +182,10 @@ Serve.prototype.go = function () { if (self.data.redirect_to_published_msg) { self.redirect(self.app.render.toUrl(publishedMsg.key)) } else { - self.publishedMsg = publishedMsg - self.handle() + var u = Url.parse(self.req.url) + var q = u.query || (u.query = {}) + q.published = publishedMsg.key + self.redirect(Url.format(u)) } } else { self.handle() @@ -1800,9 +1803,9 @@ Serve.prototype.wrapPage = function (title, searchQ) { ] }) )), - self.publishedMsg ? h('div', + self.query.published ? h('div', 'published ', - self.app.render.msgLink(self.publishedMsg, done()) + render.msgIdLink(self.query.published, done()) ) : '', // self.note, content |