diff options
author | Joas Schilling <coding@schilljs.com> | 2021-06-09 10:51:09 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-06-09 11:57:49 +0200 |
commit | b1031f3985355798c8bebcb46e362b15c462ac24 (patch) | |
tree | fe3875decd740dc0430387ceda17b13400039d59 /apps/dav | |
parent | 932a385c562481ed6a9df95af9b69fa49f267cb2 (diff) | |
download | nextcloud-server-b1031f3985355798c8bebcb46e362b15c462ac24.tar.gz nextcloud-server-b1031f3985355798c8bebcb46e362b15c462ac24.zip |
Allow apps to get photos of VObjects
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/CardDAV/PhotoCache.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php index 0761a69d60f..d3e4b2450d3 100644 --- a/apps/dav/lib/CardDAV/PhotoCache.php +++ b/apps/dav/lib/CardDAV/PhotoCache.php @@ -36,6 +36,7 @@ use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ILogger; use Sabre\CardDAV\Card; +use Sabre\VObject\Document; use Sabre\VObject\Parameter; use Sabre\VObject\Property\Binary; use Sabre\VObject\Reader; @@ -206,9 +207,28 @@ class PhotoCache { throw new NotFoundException('Avatar not found'); } + /** + * @param Card $node + * @return bool|array{body: string, Content-Type: string} + */ private function getPhoto(Card $node) { try { $vObject = $this->readCard($node->get()); + return $this->getPhotoFromVObject($vObject); + } catch (\Exception $e) { + $this->logger->logException($e, [ + 'message' => 'Exception during vcard photo parsing' + ]); + } + return false; + } + + /** + * @param Document $vObject + * @return bool|array{body: string, Content-Type: string} + */ + public function getPhotoFromVObject(Document $vObject) { + try { if (!$vObject->PHOTO) { return false; } |