Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
lightbox: Remove data-video-original-url; just use 'a href="..."' URL.
Alex Vandiverbd2c93452322
diff --git a/web/src/lightbox.ts b/web/src/lightbox.tsindex ddecfe2e7ea..2693db26164 100644--- a/web/src/lightbox.ts+++ b/web/src/lightbox.ts@@ -521,15 +521,9 @@ export function parse_media_data(media: HTMLMediaElement | HTMLImageElement): Meif (is_inline_video) {type = MediaType.InlineVideo;- // Render video from original source to reduce load on our own servers.- const original_video_url = $media.attr("data-video-original-url");- // `data-video-original-url` is only defined for external URLs in- // organizations which have camo enabled.- if (!original_video_url) {- source = preview_src;- } else {- source = encodeURI(original_video_url);- }+ // Render video from original source to reduce load on our own servers. The `url` is the+ // non-Camo'd version; `preview` is the Camo'd URL.+ source = url;} else if (is_youtube_video) {type = MediaType.YoutubeVideo;source = "https://www.youtube.com/embed/" + $parent.attr("data-id");diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex 13310accc71..4c2be3f37b2 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -577,12 +577,11 @@ class InlineVideoProcessor(markdown.treeprocessors.Treeprocessor):if is_static_or_current_realm_url(url, self.zmd.zulip_realm):# Don't rewrite videos on our own site (e.g. user uploads).continue- # Pass down both camo generated URL and the original video URL to the client.- # Camo URL is only used to generate preview of the video. When user plays the- # video, we switch to the source url to fetch the video. This allows playing- # the video with no load on our servers.+ # The href= is still set to the non-Camo'd version, which+ # is used by clients to play the full video without+ # imposing load on the Camo server; this src is used to+ # load the initial thumbnail and metadata (through Camo)video.set("src", get_camo_url(url))- video.set("data-video-original-url", url)class BacktickInlineProcessor(markdown.inlinepatterns.BacktickInlineProcessor):diff --git a/zerver/tests/fixtures/markdown_test_cases.json b/zerver/tests/fixtures/markdown_test_cases.jsonindex 7cdc47cfe6a..85517e3fce4 100644--- a/zerver/tests/fixtures/markdown_test_cases.json+++ b/zerver/tests/fixtures/markdown_test_cases.json@@ -461,13 +461,13 @@{"name": "only_inline_video","input": "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4",- "expected_output": "<div class=\"message_inline_image message_inline_video\"><a href=\"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4\"><video data-video-original-url=\"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4\" preload=\"metadata\" src=\"https://external-content.zulipcdn.net/external_content/785b3eb6f6165491371895ba42ead0e3661ae44b/68747470733a2f2f66696c652d6578616d706c65732d636f6d2e6769746875622e696f2f75706c6f6164732f323031372f30342f66696c655f6578616d706c655f4d50345f3438305f315f354d472e6d7034\"></video></a></div>",+ "expected_output": "<div class=\"message_inline_image message_inline_video\"><a href=\"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4\"><video preload=\"metadata\" src=\"https://external-content.zulipcdn.net/external_content/785b3eb6f6165491371895ba42ead0e3661ae44b/68747470733a2f2f66696c652d6578616d706c65732d636f6d2e6769746875622e696f2f75706c6f6164732f323031372f30342f66696c655f6578616d706c655f4d50345f3438305f315f354d472e6d7034\"></video></a></div>","backend_only_rendering": true},{"name": "only_named_inline_video","input": "[Google link](https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4)",- "expected_output": "<p><a href=\"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4\">Google link</a></p>\n<div class=\"message_inline_image message_inline_video\"><a href=\"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4\" title=\"Google link\"><video data-video-original-url=\"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4\" preload=\"metadata\" src=\"https://external-content.zulipcdn.net/external_content/785b3eb6f6165491371895ba42ead0e3661ae44b/68747470733a2f2f66696c652d6578616d706c65732d636f6d2e6769746875622e696f2f75706c6f6164732f323031372f30342f66696c655f6578616d706c655f4d50345f3438305f315f354d472e6d7034\"></video></a></div>",+ "expected_output": "<p><a href=\"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4\">Google link</a></p>\n<div class=\"message_inline_image message_inline_video\"><a href=\"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4\" title=\"Google link\"><video preload=\"metadata\" src=\"https://external-content.zulipcdn.net/external_content/785b3eb6f6165491371895ba42ead0e3661ae44b/68747470733a2f2f66696c652d6578616d706c65732d636f6d2e6769746875622e696f2f75706c6f6164732f323031372f30342f66696c655f6578616d706c655f4d50345f3438305f315f354d472e6d7034\"></video></a></div>","backend_only_rendering": true,"text_content": "Google link\n"},