From 36bad0c31f6fb1afce2d311b72f5f9661be6af97 Mon Sep 17 00:00:00 2001
From: Penar Musaraj
Date: Wed, 15 Jul 2020 18:36:51 -0400
Subject: [PATCH] FIX: Preload metadata for audio/video when secure media
enabled
Fixes an issue with missing video previews. Should have no side effects now that presigned URLs expire after 5 minutes.
---
.../addon/engines/discourse-markdown-it.js | 15 +++------
test/javascripts/lib/pretty-text-test.js | 31 ++-----------------
2 files changed, 6 insertions(+), 40 deletions(-)
diff --git a/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown-it.js b/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown-it.js
index 358595d2485..5e7ef24c2ac 100644
--- a/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown-it.js
+++ b/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown-it.js
@@ -144,23 +144,21 @@ export function extractDataAttribute(str) {
function videoHTML(token, opts) {
const src = token.attrGet("src");
const origSrc = token.attrGet("data-orig-src");
- const preloadType = opts.secureMedia ? "none" : "metadata";
const dataOrigSrcAttr = origSrc !== null ? `data-orig-src="${origSrc}"` : "";
return ``;
}
-function audioHTML(token, opts) {
+function audioHTML(token) {
const src = token.attrGet("src");
const origSrc = token.attrGet("data-orig-src");
- const preloadType = opts.secureMedia ? "none" : "metadata";
const dataOrigSrcAttr = origSrc !== null ? `data-orig-src="${origSrc}"` : "";
- return `
`,
- "It returns the correct video player HTML"
- );
-});
-
-QUnit.test("audio - secure media enabled", assert => {
- assert.cookedOptions(
- "![young americans|audio](upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp3)",
- { siteSettings: { secure_media: true } },
- `
-
`,
- "It returns the correct audio player HTML"
- );
-});
-
QUnit.test("video", assert => {
assert.cooked(
"![baby shark|video](upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4)",
@@ -1084,7 +1057,7 @@ QUnit.test("video - mapped url - secure media enabled", assert => {
},
`