summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-07-21 09:57:56 -0100
committerGitHub <noreply@github.com>2019-07-21 09:57:56 -0100
commit0b84625c9238e139863b0794a460c75505b66bc9 (patch)
tree8cf7aa22df67e4c5605998db461f50ea6f8180a0
parent523e08505ceca0b358b136fc6b9c341eedec9913 (diff)
parent201196a7d734c193d5a7f28a9394655a62c0d7f3 (diff)
Merge pull request #626 from StCyr/stCyr_showAttachments
show post attachments
-rw-r--r--appinfo/routes.php4
-rw-r--r--composer.json1
-rw-r--r--composer.lock65
-rw-r--r--lib/Controller/LocalController.php25
-rw-r--r--lib/Controller/NavigationController.php59
-rw-r--r--lib/Db/CacheDocumentsRequest.php3
-rw-r--r--lib/Db/CacheDocumentsRequestBuilder.php2
-rw-r--r--lib/Migration/Version0002Date20190717000001.php105
-rw-r--r--lib/Model/ActivityPub/Object/Document.php30
-rw-r--r--lib/Service/CacheDocumentService.php70
-rw-r--r--lib/Service/DocumentService.php27
-rw-r--r--package-lock.json4407
-rw-r--r--package.json1
-rw-r--r--src/components/PostAttachment.vue78
-rw-r--r--src/components/TimelinePost.vue10
-rw-r--r--src/main.js2
16 files changed, 3906 insertions, 983 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 8d293d13..85578a5d 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -45,6 +45,8 @@ return [
],
['name' => 'Navigation#documentGet', 'url' => '/document/get', 'verb' => 'GET'],
['name' => 'Navigation#documentGetPublic', 'url' => '/document/public', 'verb' => 'GET'],
+ ['name' => 'Navigation#resizedGet', 'url' => '/document/get/resized', 'verb' => 'GET'],
+ ['name' => 'Navigation#resizedGetPublic', 'url' => '/document/public/resized', 'verb' => 'GET'],
['name' => 'ActivityPub#actor', 'url' => '/users/{username}', 'verb' => 'GET'],
['name' => 'ActivityPub#actorAlias', 'url' => '/@{username}/', 'verb' => 'GET'],
@@ -69,6 +71,8 @@ return [
['name' => 'Local#streamLiked', 'url' => '/api/v1/stream/liked', 'verb' => 'GET'],
['name' => 'Local#streamAccount', 'url' => '/api/v1/account/{username}/stream', 'verb' => 'GET'],
+ ['name' => 'Local#postData', 'url' => '/local/v1/post', 'verb' => 'GET'],
+
['name' => 'Local#postCreate', 'url' => '/api/v1/post', 'verb' => 'POST'],
['name' => 'Local#postDelete', 'url' => '/api/v1/post', 'verb' => 'DELETE'],
diff --git a/composer.json b/composer.json
index 6666aa5d..f009f3b3 100644
--- a/composer.json
+++ b/composer.json
@@ -16,6 +16,7 @@
},
"require": {
"daita/my-small-php-tools": "dev-master",
+ "gumlet/php-image-resize": "1.9.*",
"friendica/json-ld": "^1.0"
},
"require-dev": {
diff --git a/composer.lock b/composer.lock
index 27758a2a..4c5f9b2d 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "d711d18021f3044f1dbf97c6a423d2ac",
+ "content-hash": "f93a783c86bad53b0b8486db3fc61380",
"packages": [
{
"name": "daita/my-small-php-tools",
@@ -12,12 +12,12 @@
"source": {
"type": "git",
"url": "https://github.com/daita/my-small-php-tools.git",
- "reference": "45a543b86ad93ea36845e5bc32ca03320b6cfa9c"
+ "reference": "6ba571ffa6bda6f32fcc6529a474ccc777eb1fb2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/45a543b86ad93ea36845e5bc32ca03320b6cfa9c",
- "reference": "45a543b86ad93ea36845e5bc32ca03320b6cfa9c",
+ "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/6ba571ffa6bda6f32fcc6529a474ccc777eb1fb2",
+ "reference": "6ba571ffa6bda6f32fcc6529a474ccc777eb1fb2",
"shasum": ""
},
"require": {
@@ -40,7 +40,7 @@
}
],
"description": "My small PHP Tools",
- "time": "2019-06-21T16:40:45+00:00"
+ "time": "2019-07-12T20:21:51+00:00"
},
{
"name": "friendica/json-ld",
@@ -85,6 +85,61 @@
"jsonld"
],
"time": "2018-10-08T20:41:00+00:00"
+ },
+ {
+ "name": "gumlet/php-image-resize",
+ "version": "1.9.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/gumlet/php-image-resize.git",
+ "reference": "06339a9c1b167acd58173db226f57957a6617547"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/gumlet/php-image-resize/zipball/06339a9c1b167acd58173db226f57957a6617547",
+ "reference": "06339a9c1b167acd58173db226f57957a6617547",
+ "shasum": ""
+ },
+ "require": {
+ "ext-fileinfo": "*",
+ "ext-gd": "*",
+ "php": ">=5.5.0"
+ },
+ "require-dev": {
+ "apigen/apigen": "^4.1",
+ "ext-exif": "*",
+ "ext-gd": "*",
+ "php-coveralls/php-coveralls": "^2.1",
+ "phpunit/phpunit": "^4.8"
+ },
+ "suggest": {
+ "ext-exif": "Auto-rotate jpeg files"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Gumlet\\": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Aditya Patadia",
+ "homepage": "http://aditya.patadia.org/"
+ }
+ ],
+ "description": "PHP class to re-size and scale images",
+ "homepage": "https://github.com/gumlet/php-image-resize",
+ "keywords": [
+ "image",
+ "php",
+ "resize",
+ "scale"
+ ],
+ "time": "2019-01-01T13:53:00+00:00"
}
],
"packages-dev": [
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php
index b731be2e..107c57e5 100644
--- a/lib/Controller/LocalController.php
+++ b/lib/Controller/LocalController.php
@@ -183,6 +183,26 @@ class LocalController extends Controller {
/**
+ * get info about a post (limited to viewer rights).
+ *
+ * @NoAdminRequired
+ *
+ * @param string $id
+ *
+ * @return DataResponse
+ */
+ public function postData(string $id): DataResponse {
+ try {
+ $this->initViewer(true);
+
+ return $this->directSuccess($this->noteService->getNoteById($id, true));
+ } catch (Exception $e) {
+ return $this->fail($e);
+ }
+ }
+
+
+ /**
* Delete your own post.
*
* @NoAdminRequired
@@ -703,9 +723,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;
diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php
index c4438e5a..b613fb1e 100644
--- a/lib/Controller/NavigationController.php
+++ b/lib/Controller/NavigationController.php
@@ -34,6 +34,7 @@ use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
use daita\MySmallPhpTools\Traits\TArrayTools;
use Exception;
use OC;
+use OC\AppFramework\Http;
use OC\User\NoUserException;
use OCA\Social\AppInfo\Application;
use OCA\Social\Exceptions\AccountAlreadyExistsException;
@@ -139,7 +140,7 @@ class NavigationController extends Controller {
'firstrun' => false,
'setup' => false,
'isAdmin' => OC::$server->getGroupManager()
- ->isAdmin($this->userId),
+ ->isAdmin($this->userId),
'cliUrl' => $this->getCliUrl()
]
];
@@ -282,17 +283,61 @@ class NavigationController extends Controller {
/**
* @NoAdminRequired
+ * @NoCSRFRequired
*
* @param string $id
*
* @return Response
*/
public function documentGet(string $id): Response {
+ try {
+ $mime = '';
+ $file = $this->documentService->getFromCache($id, $mime);
+
+ return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]);
+
+ } catch (Exception $e) {
+ return $this->fail($e);
+ }
+ }
+
+ /**
+ *
+ * @PublicPage
+ * @NoCSRFRequired
+ *
+ * @param string $id
+ *
+ * @return Response
+ */
+ public function documentGetPublic(string $id): Response {
try {
- $file = $this->documentService->getFromCache($id);
+ $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);
+ }
+ }
+
+
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ *
+ * @param string $id
+ *
+ * @return Response
+ */
+ public function resizedGet(string $id): Response {
+
+ try {
+ $mime = '';
+ $file = $this->documentService->getResizedFromCache($id, $mime);
+
+ return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]);
} catch (Exception $e) {
return $this->fail($e);
}
@@ -307,15 +352,17 @@ class NavigationController extends Controller {
*
* @return Response
*/
- public function documentGetPublic(string $id): Response {
+ public function resizedGetPublic(string $id): Response {
try {
- $file = $this->documentService->getFromCache($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);
}
}
}
+
diff --git a/lib/Db/CacheDocumentsRequest.php b/lib/Db/CacheDocumentsRequest.php
index c8297599..bd7da9e9 100644
--- a/lib/Db/CacheDocumentsRequest.php
+++ b/lib/Db/CacheDocumentsRequest.php
@@ -56,6 +56,7 @@ class CacheDocumentsRequest extends CacheDocumentsRequestBuilder {
->setValue('mime_type', $qb->createNamedParameter($document->getMimeType()))
->setValue('error', $qb->createNamedParameter($document->getError()))
->setValue('local_copy', $qb->createNamedParameter($document->getLocalCopy()))
+ ->setValue('resized_copy', $qb->createNamedParameter($document->getResizedCopy()))
->setValue('parent_id', $qb->createNamedParameter($document->getParentId()))
->setValue('public', $qb->createNamedParameter(($document->isPublic()) ? '1' : '0'));
@@ -86,6 +87,7 @@ class CacheDocumentsRequest extends CacheDocumentsRequestBuilder {
->set('mime_type', $qb->createNamedParameter($document->getMimeType()))
->set('error', $qb->createNamedParameter($document->getError()))
->set('local_copy', $qb->createNamedParameter($document->getLocalCopy()))
+ ->set('resized_copy', $qb->createNamedParameter($document->getResizedCopy()))
->set('parent_id', $qb->createNamedParameter($document->getParentId()))
->set('public', $qb->createNamedParameter(($document->isPublic()) ? '1' : '0'));
@@ -127,6 +129,7 @@ class CacheDocumentsRequest extends CacheDocumentsRequestBuilder {
$qb = $this->getCacheDocumentsUpdateSql();
$this->limitToIdString($qb, $document->getId());
$qb->set('local_copy', $qb->createNamedParameter($document->getLocalCopy()));
+ $qb->set('resized_copy', $qb->createNamedParameter($document->getResizedCopy()));
$qb->set('error', $qb->createNamedParameter($document->getError()));
$qb->execute();
diff --git a/lib/Db/CacheDocumentsRequestBuilder.php b/lib/Db/CacheDocumentsRequestBuilder.php
index a75c4a0a..10b91f79 100644
--- a/lib/Db/CacheDocumentsRequestBuilder.php
+++ b/lib/Db/CacheDocumentsRequestBuilder.php
@@ -77,7 +77,7 @@ class CacheDocumentsRequestBuilder extends CoreRequestBuilder {
/** @noinspection PhpMethodParametersCountMismatchInspection */
$qb->select(
'cd.id', 'cd.type', 'cd.parent_id', 'cd.media_type', 'cd.mime_type', 'cd.url',
- 'cd.local_copy', 'cd.public', 'cd.error', 'cd.creation', 'cd.caching'
+ 'cd.local_copy', 'cd.public', 'cd.error', 'cd.creation', 'cd.caching', 'cd.resized_copy'
)
->from(self::TABLE_CACHE_DOCUMENTS, 'cd');
diff --git a/lib/Migration/Version0002Date20190717000001.php b/lib/Migration/Version0002Date20190717000001.php
new file mode 100644
index 00000000..7864e31b
--- /dev/null
+++ b/lib/Migration/Version0002Date20190717000001.php
@@ -0,0 +1,105 @@
+<?php
+declare(strict_types=1);
+
+
+/**
+ * Nextcloud - Social Support
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Maxence Lange <maxence@artificial-owl.com>
+ * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCA\Social\Migration;
+
+
+use Closure;
+use Doctrine\DBAL\Schema\SchemaException;
+use Doctrine\DBAL\Types\Type;
+use Exception;
+use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+
+/**
+ * Class Version0002Date20190717000001
+ *
+ * @package OCA\Social\Migration
+ */
+class Version0002Date20190717000001 extends SimpleMigrationStep {
+
+
+ /** @var IDBConnection */
+ private $connection;
+
+
+ /**
+ * @param IDBConnection $connection
+ */
+ public function __construct(IDBConnection $connection) {
+ $this->connection = $connection;
+ }
+
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ *
+ * @return ISchemaWrapper
+ * @throws SchemaException
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options
+ ): ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+ if (!$schema->hasTable('social_a2_cache_documts')) {
+ return $schema;
+ }
+
+ $table = $schema->getTable('social_a2_cache_documts');
+ if (!$table->hasColumn('resized_copy')) {
+ $table->addColumn(
+ 'resized_copy', Type::TEXT,
+ [
+ 'notnull' => true
+ ]
+ );
+ }
+
+ return $schema;
+ }
+
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ *
+ * @throws Exception
+ */
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
+ }
+
+}
+
diff --git a/lib/Model/ActivityPub/Object/Document.php b/lib/Model/ActivityPub/Object/Document.php
index ca6e4a6f..6685fb62 100644
--- a/lib/Model/ActivityPub/Object/Document.php
+++ b/lib/Model/ActivityPub/Object/Document.php
@@ -59,6 +59,9 @@ class Document extends ACore implements JsonSerializable {
/** @var string */
private $localCopy = '';
+ /** @var string */
+ private $resizedCopy = '';
+
/** @var int */
private $caching = 0;
@@ -141,6 +144,25 @@ class Document extends ACore implements JsonSerializable {
/**
+ * @return string
+ */
+ public function getResizedCopy(): string {
+ return $this->resizedCopy;
+ }
+
+ /**
+ * @param string $resizedCopy
+ *
+ * @return Document
+ */
+ public function setResizedCopy(string $resizedCopy): Document {
+ $this->resizedCopy = $resizedCopy;
+
+ return $this;
+ }
+
+
+ /**
* @return bool
*/
public function isPublic(): bool {
@@ -244,6 +266,7 @@ class Document extends ACore implements JsonSerializable {
$this->setPublic(($this->getInt('public', $data, 0) === 1) ? true : false);
$this->setError($this->getInt('error', $data, 0));
$this->setLocalCopy($this->get('local_copy', $data, ''));
+ $this->setResizedCopy($this->get('resized_copy', $data, ''));
$this->setMediaType($this->get('media_type', $data, ''));
$this->setMimeType($this->get('mime_type', $data, ''));
$this->setParentId($this->get('parent_id', $data, ''));
@@ -266,9 +289,10 @@ class Document extends ACore implements JsonSerializable {
$result = array_merge(
parent::jsonSerialize(),
[
- 'mediaType' => $this->getMediaType(),
- 'mimeType' => $this->getMimeType(),
- 'localCopy' => $this->getLocalCopy()
+ 'mediaType' => $this->getMediaType(),
+ 'mimeType' => $this->getMimeType(),
+ 'localCopy' => $this->getLocalCopy(),
+ 'resizedCopy' => $this->getResizedCopy()
]
);
diff --git a/lib/Service/CacheDocumentService.php b/lib/Service/CacheDocumentService.php
index 84aa32a2..b147c8f6 100644
--- a/lib/Service/CacheDocumentService.php
+++ b/lib/Service/CacheDocumentService.php
@@ -35,6 +35,8 @@ use daita\MySmallPhpTools\Model\Request;
use daita\MySmallPhpTools\Traits\TArrayTools;
use daita\MySmallPhpTools\Traits\TStringTools;
use Exception;
+use Gumlet\ImageResize;
+use Gumlet\ImageResizeException;
use OCA\Social\Exceptions\CacheContentException;
use OCA\Social\Exceptions\CacheContentMimeTypeException;
use OCA\Social\Exceptions\CacheDocumentDoesNotExistException;
@@ -45,6 +47,7 @@ use OCA\Social\Exceptions\RequestResultSizeException;
use OCA\Social\Exceptions\RequestServerException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\UnauthorizedFediverseException;
+use OCA\Social\Model\ActivityPub\Object\Document;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
@@ -58,6 +61,9 @@ class CacheDocumentService {
use TStringTools;
+ const RESIZED_WIDTH = 280;
+ const RESIZED_HEIGHT = 180;
+
/** @var IAppData */
private $appData;
@@ -91,11 +97,9 @@ class CacheDocumentService {
/**
- * @param string $url
- *
+ * @param Document $document
* @param string $mime
*
- * @return string
* @throws CacheContentMimeTypeException
* @throws MalformedArrayException
* @throws NotFoundException
@@ -108,10 +112,36 @@ class CacheDocumentService {
* @throws SocialAppConfigException
* @throws UnauthorizedFediverseException
*/
- public function saveRemoteFileToCache(string $url, &$mime = '') {
+ public function saveRemoteFileToCache(Document $document, &$mime = '') {
+ $content = $this->retrieveContent($document->getUrl());
- $filename = $this->uuid();
+ // To get the mime type, we create a temp file
+ $tmpFile = tmpfile();
+ $tmpPath = stream_get_meta_data($tmpFile)['uri'];
+ fwrite($tmpFile, $content);
+ $mime = mime_content_type($tmpPath);
+ fclose($tmpFile);
+ $this->filterMimeTypes($mime);
+
+ $filename = $this->saveContentToCache($content);
+ $document->setLocalCopy($filename);
+ $this->resizeImage($content);
+ $resized = $this->saveContentToCache($content);
+ $document->setResizedCopy($resized);
+ }
+
+
+ /**
+ * @param string $content
+ *
+ * @return string
+ * @throws NotPermittedException
+ * @throws NotFoundException
+ */
+ private function saveContentToCache(string $content): string {
+
+ $filename = $this->uuid();
// creating a path aa/bb/cc/dd/ from the filename aabbccdd-0123-[...]
$path = chunk_split(substr($filename, 0, 8), 2, '/');
@@ -121,17 +151,6 @@ class CacheDocumentService {
$folder = $this->appData->newFolder($path);
}
- $content = $this->retrieveContent($url);
-
- // To get the mime type, we create a temp file
- $tmpFile = tmpfile();
- $tmpPath = stream_get_meta_data($tmpFile)['uri'];
- fwrite($tmpFile, $content);
- $mime = mime_content_type($tmpPath);
- fclose($tmpFile);
-
- $this->filterMimeTypes($mime);
-
$cache = $folder->newFile($filename);
$cache->putContent($content);
@@ -160,6 +179,23 @@ class CacheDocumentService {
throw new CacheContentMimeTypeException();
}
+
+ /**
+ * @param $content
+ */
+ private function resizeImage(&$content) {
+ try {
+ $image = ImageResize::createFromString($content);
+ $image->quality_jpg = 100;
+ $image->quality_png = 9;
+
+ $image->resizeToBestFit(self::RESIZED_WIDTH, self::RESIZED_HEIGHT);
+ $content = $image->getImageAsString();
+ } catch (ImageResizeException $e) {
+ }
+ }
+
+
/**
* @param string $path
*
@@ -167,7 +203,7 @@ class CacheDocumentService {
* @throws CacheContentException
* @throws CacheDocumentDoesNotExistException
*/
- public function getContentFromCache(string $path) {
+ public function getContentFromCache(string $path): ISimpleFile {
if ($path === '') {
throw new CacheDocumentDoesNotExistException();
}
diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php
index 4fedac0c..c5318bc3 100644
--- a/lib/Service/DocumentService.php
+++ b/lib/Service/DocumentService.php
@@ -143,9 +143,7 @@ class DocumentService {
$this->cacheDocumentsRequest->initCaching($document);
try {
- $localCopy = $this->cacheService->saveRemoteFileToCache($document->getUrl(), $mime);
- $document->setMimeType($mime);
- $document->setLocalCopy($localCopy);
+ $this->cacheService->saveRemoteFileToCache($document, $mime);
$this->cacheDocumentsRequest->endCaching($document);
$this->streamRequest->updateAttachments($document);
@@ -192,8 +190,28 @@ class DocumentService {
/**
* @param string $id
+ * @param string $mime
+ * @param bool $public
*
+ * @return ISimpleFile
+ * @throws CacheContentException
+ * @throws CacheDocumentDoesNotExistException
+ * @throws MalformedArrayException
+ * @throws RequestResultNotJsonException
+ * @throws SocialAppConfigException
+ */
+ public function getResizedFromCache(string $id, string &$mime = '', bool $public = false) {
+ $document = $this->cacheRemoteDocument($id, $public);
+ $mime = $document->getMimeType();
+
+ return $this->cacheService->getContentFromCache($document->getResizedCopy());
+ }
+
+
+ /**
+ * @param string $id
* @param bool $public
+ * @param string $mimeType
*
* @return ISimpleFile
* @throws CacheContentException
@@ -202,8 +220,9 @@ class DocumentService {
* @throws RequestResultNotJsonException
* @throws SocialAppConfigException
*/
- public function getFromCache(string $id, bool $public = false) {
+ public function getFromCache(string $id, string &$mimeType = '', bool $public = false) {
$document = $this->cacheRemoteDocument($id, $public);
+ $mimeType = $document->getMimeType();
return $this->cacheService->getContentFromCache($document->getLocalCopy());
}
diff --git a/package-lock.json b/package-lock.json
index f64e2878..52c33043 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,14 +14,14 @@
}
},
"@babel/core": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.5.0.tgz",
- "integrity": "sha512-6Isr4X98pwXqHvtigw71CKgmhL1etZjPs5A67jL/w0TkLM9eqmFR40YrnJvEc1WnMZFsskjsmid8bHZyxKEAnw==",
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.5.4.tgz",
+ "integrity": "sha512-+DaeBEpYq6b2+ZmHx3tHspC+ZRflrvLqwfv8E3hNr5LVQoyBnL8RPKSBCg+rK2W2My9PWlujBiqd0ZPsR9Q6zQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"@babel/generator": "^7.5.0",
- "@babel/helpers": "^7.5.0",
+ "@babel/helpers": "^7.5.4",
"@babel/parser": "^7.5.0",
"@babel/template": "^7.4.4",
"@babel/traverse": "^7.5.0",
@@ -49,6 +49,12 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
+ },
+ "source-map": {
+ "version": "0.5.7",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
+ "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
+ "dev": true
}
}
},
@@ -63,6 +69,14 @@
"lodash": "^4.17.11",
"source-map": "^0.5.0",
"trim-right": "^1.0.1"
+ },
+ "dependencies": {
+ "source-map": {
+ "version": "0.5.7",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
+ "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
+ "dev": true
+ }
}
},
"@babel/helper-annotate-as-pure": {
@@ -258,9 +272,9 @@
}
},
"@babel/helpers": {
- "version": "7.5.1",
- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.5.1.tgz",
- "integrity": "sha512-rVOTDv8sH8kNI72Unenusxw6u+1vEepZgLxeV+jHkhsQlYhzVhzL1EpfoWT7Ub3zpWSv2WV03V853dqsnyoQzA==",
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.5.4.tgz",
+ "integrity": "sha512-6LJ6xwUEJP51w0sIgKyfvFMJvIb9mWAfohJp0+m6eHJigkFdcH8duZ1sfhn0ltJRzwUIT/yqqhdSfRpCpL7oow==",
"dev": true,
"requires": {
"@babel/template": "^7.4.4",
@@ -282,8 +296,7 @@
"@babel/parser": {
"version": "7.5.0",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.0.tgz",
- "integrity": "sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA==",
- "dev": true
+ "integrity": "sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA=="
},
"@babel/plugin-proposal-async-generator-functions": {
"version": "7.2.0",
@@ -317,9 +330,9 @@
}
},
"@babel/plugin-proposal-object-rest-spread": {
- "version": "7.5.1",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.5.1.tgz",
- "integrity": "sha512-PVGXx5LYHcT7L4MdoE+rM5uq68IKlvU9lljVQ4OXY6aUEnGvezcGbM4VNY57Ug+3R2Zg/nYHlEdiWoIBoRA0mw==",
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.5.4.tgz",
+ "integrity": "sha512-KCx0z3y7y8ipZUMAEEJOyNi11lMb/FOPUjjB113tfowgw0c16EGYos7worCKBcUAh2oG+OBnoUhsnTSoLpV9uA==",
"dev": true,
"requires": {
"@babel/helper-plugin-utils": "^7.0.0",
@@ -700,10 +713,19 @@
"regexpu-core": "^4.5.4"
}
},
+ "@babel