kopia lustrzana https://github.com/nextcloud/social
cache on-the-fly
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/53/head
rodzic
1999f06ada
commit
a7451538d8
|
@ -39,7 +39,6 @@ use OCA\Social\Exceptions\CacheDocumentDoesNotExistException;
|
||||||
use OCA\Social\Model\ActivityPub\ACore;
|
use OCA\Social\Model\ActivityPub\ACore;
|
||||||
use OCA\Social\Model\ActivityPub\Document;
|
use OCA\Social\Model\ActivityPub\Document;
|
||||||
use OCA\Social\Service\CacheService;
|
use OCA\Social\Service\CacheService;
|
||||||
use OCA\Social\Service\ICoreService;
|
|
||||||
use OCA\Social\Service\MiscService;
|
use OCA\Social\Service\MiscService;
|
||||||
use OCP\Files\NotPermittedException;
|
use OCP\Files\NotPermittedException;
|
||||||
use OCP\Files\SimpleFS\ISimpleFile;
|
use OCP\Files\SimpleFS\ISimpleFile;
|
||||||
|
@ -77,13 +76,14 @@ class DocumentService implements ICoreService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $id
|
* @param string $id
|
||||||
|
* @param bool $public
|
||||||
*
|
*
|
||||||
* @return Document
|
* @return Document
|
||||||
* @throws CacheDocumentDoesNotExistException
|
* @throws CacheDocumentDoesNotExistException
|
||||||
* @throws NotPermittedException
|
* @throws NotPermittedException
|
||||||
*/
|
*/
|
||||||
public function cacheRemoteDocument(string $id) {
|
public function cacheRemoteDocument(string $id, bool $public = false) {
|
||||||
$document = $this->cacheDocumentsRequest->getById($id);
|
$document = $this->cacheDocumentsRequest->getById($id, $public);
|
||||||
if ($document->getLocalCopy() !== '') {
|
if ($document->getLocalCopy() !== '') {
|
||||||
return $document;
|
return $document;
|
||||||
}
|
}
|
||||||
|
@ -117,9 +117,10 @@ class DocumentService implements ICoreService {
|
||||||
* @return ISimpleFile
|
* @return ISimpleFile
|
||||||
* @throws CacheContentException
|
* @throws CacheContentException
|
||||||
* @throws CacheDocumentDoesNotExistException
|
* @throws CacheDocumentDoesNotExistException
|
||||||
|
* @throws NotPermittedException
|
||||||
*/
|
*/
|
||||||
public function getFromCache(string $id, bool $public = false) {
|
public function getFromCache(string $id, bool $public = false) {
|
||||||
$document = $this->cacheDocumentsRequest->getById($id, $public);
|
$document = $this->cacheRemoteDocument($id, $public);
|
||||||
|
|
||||||
return $this->cacheService->getContentFromCache($document->getLocalCopy());
|
return $this->cacheService->getContentFromCache($document->getLocalCopy());
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue