From cb3aa7e2332964780e817185c05d6f98870496d7 Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 30 May 2017 09:56:28 -1000 Subject: Include blob size even when just mentioning --- lib/serve.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/serve.js b/lib/serve.js index 1d8d8af..6aed742 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -2043,6 +2043,7 @@ Serve.prototype.composer = function (opts, cb) { done(cb) function prepareContent(cb) { + var done = multicb({pluck: 1}) content = { type: 'post', text: String(data.text).replace(/\r\n/g, '\n'), @@ -2067,6 +2068,13 @@ Serve.prototype.composer = function (opts, cb) { if (id) mention.link = id else return false } + if (mention.link && mention.link[0] === '&' && mention.size == null) { + var linkCb = done() + self.app.sbot.blobs.size(mention.link, function (err, size) { + if (!err && size != null) mention.size = size + linkCb() + }) + } return true }) if (mentions.length) content.mentions = mentions @@ -2087,7 +2095,10 @@ Serve.prototype.composer = function (opts, cb) { content.branch = u.fromArray(opts.branches) || undefined } if (channel) content.channel = data.channel - cb(null, content) + + done(function (err) { + cb(err, content) + }) } function preview(raw, cb) { -- cgit v1.2.3