From 24765da30eaa84bc6084932ad4b80e8fa73b7521 Mon Sep 17 00:00:00 2001 From: cel Date: Thu, 22 Aug 2019 17:52:51 -0700 Subject: Use Post/Redirect/Get for all message publishing Fix %1/jp2WMT0l7l+u6yvn1axK5WqkfoQlSuuZkvWlvVEyE=.sha256 --- lib/render.js | 6 +++--- 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 -- cgit v1.2.3