From 6eb35516652cc56075247a8e0ac5a5acd5ca27b7 Mon Sep 17 00:00:00 2001 From: or-else Date: Fri, 15 Jun 2018 14:34:06 +0300 Subject: [PATCH] add attachment's URLs to message header --- drafty.js | 2 +- index.html | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drafty.js b/drafty.js index 369af8ab..6de247e7 100644 --- a/drafty.js +++ b/drafty.js @@ -129,7 +129,7 @@ Sample JSON representation of the text above: }, IM: { open: function(data) { - // Don't use data.ref for preview: it's a security risk. + // Don't use data.ref for preview: it's a security risk. var previewUrl = base64toObjectUrl(data.val, data.mime); var downloadUrl = data.ref ? data.ref : previewUrl; var res = (data.name ? '' : '') + diff --git a/index.html b/index.html index 5068f38b..ea911507 100644 --- a/index.html +++ b/index.html @@ -4460,13 +4460,23 @@ // Check if the message is formatted. var dft = Drafty.parse(msg) || msg; if (Drafty.isPlainText(dft)) { - // The message is simple text. Sned if as text/plain. + // The message is unformatted text. Send if as text/plain. topic.publish(msg).catch(function(err) { instance.handleError(err.message, "err"); });; } else { + // The message is a Drafty object. + var attachments = []; + dft.attachments(function(data) { + if (data.ref) { + attachments.push(data.ref); + } + }); + if (attachments.length < 1) { + attachments = null; + } // Formatted message. Send it as a Drafty object. - topic.publish(dft, undefined, Drafty.getContentType()).catch(function(err) { + topic.publish(dft, undefined, Drafty.getContentType(), attachments).catch(function(err) { instance.handleError(err.message, "err"); }); }