summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2021-06-09 14:24:49 +0200
committerGitHub <noreply@github.com>2021-06-09 14:24:49 +0200
commit97e427f09f54b25f1d143665842a45b141e5427e (patch)
tree32083268bb661a66644652dff91d0df02f80d890
parentc613c8ceac2e35c1b883e66618a83d305b471af1 (diff)
parentb1031f3985355798c8bebcb46e362b15c462ac24 (diff)
downloadnextcloud-server-97e427f09f54b25f1d143665842a45b141e5427e.tar.gz
nextcloud-server-97e427f09f54b25f1d143665842a45b141e5427e.zip
Merge pull request #27436 from nextcloud/techdebt/noid/all-apps-to-get-photos-from-vobjects-too
Allow apps to get photos of VObjects
-rw-r--r--apps/dav/lib/CardDAV/PhotoCache.php20
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;
}