From c6fe7a432024c4fc0800dcdd361aaa7c1383f239 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Wed, 19 Nov 2014 19:46:40 +0100 Subject: [PATCH] Changed downloading YouTube posts in backend Trying to download YouTube posts by visiting backend directly results in a redirect to YouTube instead of showing an ugly error. --- src/Controllers/PostContentController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Controllers/PostContentController.php b/src/Controllers/PostContentController.php index 64bd38c4..ae8c58d7 100644 --- a/src/Controllers/PostContentController.php +++ b/src/Controllers/PostContentController.php @@ -2,6 +2,7 @@ namespace Szurubooru\Controllers; use Szurubooru\Config; use Szurubooru\Dao\PublicFileDao; +use Szurubooru\Entities\Post; use Szurubooru\Helpers\MimeHelper; use Szurubooru\Router; use Szurubooru\Services\NetworkingService; @@ -45,6 +46,12 @@ final class PostContentController extends AbstractController $post->getName(), strtolower(MimeHelper::getExtension($post->getContentMimeType()))); + if ($post->getContentType() === Post::POST_TYPE_YOUTUBE) + { + $this->networkingService->nonCachedRedirect($post->getOriginalFileName()); + return; + } + $this->networkingService->serveFile($this->fileDao->getFullPath($post->getContentPath()), $customFileName); }