send header on documentGet

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/626/head
Maxence Lange 2019-07-20 17:19:59 -01:00
rodzic eadc04fc61
commit 2f54495805
4 zmienionych plików z 23 dodań i 14 usunięć

Wyświetl plik

@ -701,9 +701,10 @@ class LocalController extends Controller {
$actor = $this->cacheActorService->getFromId($id);
if ($actor->gotIcon()) {
$avatar = $actor->getIcon();
$document = $this->documentService->getFromCache($avatar->getId());
$document = $this->documentService->getFromCache($avatar->getId(), $mime);
$response = new FileDisplayResponse($document);
$response =
new FileDisplayResponse($document, Http::STATUS_OK, ['Content-Type' => $mime]);
$response->cacheFor(86400);
return $response;

Wyświetl plik

@ -291,9 +291,11 @@ class NavigationController extends Controller {
*/
public function documentGet(string $id): Response {
try {
$file = $this->documentService->getFromCache($id);
$mime = '';
$file = $this->documentService->getFromCache($id, $mime);
return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]);
return new FileDisplayResponse($file, Http::STATUS_OK);
} catch (Exception $e) {
return $this->fail($e);
}
@ -311,9 +313,10 @@ class NavigationController extends Controller {
public function documentGetPublic(string $id): Response {
try {
$file = $this->documentService->getFromCache($id, true);
$mime = '';
$file = $this->documentService->getFromCache($id, $mime, true);
return new FileDisplayResponse($file);
return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]);
} catch (Exception $e) {
return $this->fail($e);
}
@ -331,9 +334,10 @@ class NavigationController extends Controller {
public function resizedGet(string $id): Response {
try {
$file = $this->documentService->getResizedFromCache($id);
$mime = '';
$file = $this->documentService->getResizedFromCache($id, $mime);
return new FileDisplayResponse($file);
return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]);
} catch (Exception $e) {
return $this->fail($e);
}
@ -351,12 +355,14 @@ class NavigationController extends Controller {
public function resizedGetPublic(string $id): Response {
try {
$file = $this->documentService->getResizedFromCache($id, true);
$mime = '';
$file = $this->documentService->getResizedFromCache($id, $mime, true);
return new FileDisplayResponse($file);
return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]);
} catch (Exception $e) {
return $this->fail($e);
}
}
}

Wyświetl plik

@ -61,8 +61,8 @@ class CacheDocumentService {
use TStringTools;
const RESIZED_HEIGHT = 250;
const RESIZED_WIDTH = 350;
const RESIZED_WIDTH = 280;
const RESIZED_HEIGHT = 180;
/** @var IAppData */
private $appData;

Wyświetl plik

@ -190,6 +190,7 @@ class DocumentService {
/**
* @param string $id
* @param string $mime
* @param bool $public
*
* @return ISimpleFile
@ -199,8 +200,9 @@ class DocumentService {
* @throws RequestResultNotJsonException
* @throws SocialAppConfigException
*/
public function getResizedFromCache(string $id, bool $public = false) {
public function getResizedFromCache(string $id, string &$mime = '', bool $public = false) {
$document = $this->cacheRemoteDocument($id, $public);
$mime = $document->getMimeType();
return $this->cacheService->getContentFromCache($document->getResizedCopy());
}
@ -218,7 +220,7 @@ class DocumentService {
* @throws RequestResultNotJsonException
* @throws SocialAppConfigException
*/
public function getFromCache(string $id, bool $public = false, string &$mimeType = '') {
public function getFromCache(string $id, string &$mimeType = '', bool $public = false) {
$document = $this->cacheRemoteDocument($id, $public);
$mimeType = $document->getMimeType();