From 31f365474b6475c85d08004d1a4081b5f971fd00 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 23 Aug 2019 17:12:39 +0200 Subject: [PATCH] Fix fileHost for avatars --- www/common/common-ui-elements.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index ee4ab98b5..7656aaf1b 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1501,7 +1501,7 @@ define([ UIElements.getAvatar = function (hash) { return avatars[hash]; }; - UIElements.displayAvatar = function (Common, $container, href, name, cb) { + UIElements.displayAvatar = function (common, $container, href, name, cb) { var displayDefault = function () { var text = getFirstEmojiOrCharacter(name); var $avatar = $('', {'class': 'cp-avatar-default'}).text(text); @@ -1537,12 +1537,15 @@ define([ return; } // No password for avatars + var privateData = common.getMetadataMgr().getPrivateData(); + var origin = privateData.fileHost || privateData.origin; var secret = Hash.getSecrets('file', parsed.hash); if (secret.keys && secret.channel) { var hexFileName = secret.channel; var cryptKey = Hash.encodeBase64(secret.keys && secret.keys.cryptKey); var src = Hash.getBlobPathFromHex(hexFileName); - Common.getFileSize(hexFileName, function (e, data) { + console.log(origin + src); + common.getFileSize(hexFileName, function (e, data) { if (e || !data) { displayDefault(); return void console.error(e || "404 avatar"); @@ -1550,9 +1553,9 @@ define([ if (typeof data !== "number") { return void displayDefault(); } if (Util.bytesToMegabytes(data) > 0.5) { return void displayDefault(); } var $img = $('').appendTo($container); - $img.attr('src', src); + $img.attr('src', origin + src); $img.attr('data-crypto-key', 'cryptpad:' + cryptKey); - UIElements.displayMediatagImage(Common, $img, function (err, $image, img) { + UIElements.displayMediatagImage(common, $img, function (err, $image, img) { if (err) { return void console.error(err); } centerImage($img, $image, img); });