aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-01-28 22:58:02 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-01-29 00:20:15 -1000
commit304dc21333457363ea79c035ce9115d48ecc9855 (patch)
tree2ecff091c5f3f52e72e4e0305c793657976314a5 /lib
parentf32665ca5d41f1022f1883c573c5dd680ddca452 (diff)
downloadpatchfoo-304dc21333457363ea79c035ce9115d48ecc9855.tar.gz
patchfoo-304dc21333457363ea79c035ce9115d48ecc9855.zip
Allow setting blob link mime-types in composer
Diffstat (limited to 'lib')
-rw-r--r--lib/serve.js35
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/serve.js b/lib/serve.js
index d702ee6..810b887 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -3477,9 +3477,6 @@ Serve.prototype.composer = function (opts, cb) {
key: data.upload.key,
}
}
- if (data.blob_type && blobs[data.blob_link]) {
- blobs[data.blob_link].type = data.blob_type
- }
var channel = data.channel != null ? data.channel : opts.channel
var formNames = {}
@@ -3502,6 +3499,14 @@ Serve.prototype.composer = function (opts, cb) {
}
}
+ var blobIds = u.toArray(data.blob_id)
+ var blobTypes = u.toArray(data.blob_type)
+ for (var i = 0; i < blobIds.length && i < blobTypes.length; i++) {
+ var id = blobIds[i]
+ var blob = blobs[id] || (blobs[id] = {})
+ blob.type = blobTypes[i]
+ }
+
if (data.upload) {
var href = data.upload.link
+ (data.upload.key ? '?unbox=' + data.upload.key + '.boxs': '')
@@ -3551,6 +3556,17 @@ Serve.prototype.composer = function (opts, cb) {
return {name: name, id: id}
})
+ var blobMentions = mentions
+ .filter(function (mention) {
+ return mention
+ && typeof mention.link === 'string'
+ && mention.link[0] === '&'
+ })
+ blobMentions.forEach(function (mention) {
+ var blob = blobs[mention.link]
+ if (blob) mention.type = blob.type
+ })
+
// strip content other than names and feed ids from the recps field
if (data.recps) {
data.recps = recpsToFeedIds(data.recps)
@@ -3605,6 +3621,19 @@ Serve.prototype.composer = function (opts, cb) {
h('input', {type: 'file', name: 'emoji_upload_' + i}))
}))
] : '',
+ blobMentions.length > 0 ? [
+ h('div', h('em', 'blobs:')),
+ h('ul.mentions', blobMentions.map(function (link, i) {
+ var linkHref = self.app.render.toUrl(link.link)
+ return h('li',
+ h('a', {href: linkHref}, link.name || link.link), ': ',
+ h('input', {name: 'blob_id', type: 'hidden',
+ value: link.link}),
+ h('input', {name: 'blob_type', size: 24,
+ value: link.type, placeholder: 'application/octet-stream',
+ title: 'blob mime-type'}))
+ }))
+ ] : '',
h('table.ssb-msgs',
h('tr.msg-row',
h('td.msg-left', {colspan: 2},