diff options
author | tobiasKaminsky <tobias@kaminsky.me> | 2023-08-03 14:51:09 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-08-08 13:29:34 +0000 |
commit | 963a783747229d775267cf260f3a6851ade53fab (patch) | |
tree | 152c7a28c458f8f6edb37ea144cd10fc2ea52434 /apps/dav/lib/Connector/Sabre/FilesPlugin.php | |
parent | 9234ae4a0a98ee924cd63974e88c22c3bb3f6b21 (diff) | |
download | nextcloud-server-963a783747229d775267cf260f3a6851ade53fab.tar.gz nextcloud-server-963a783747229d775267cf260f3a6851ade53fab.zip |
expose gps data via webdav
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/FilesPlugin.php')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/FilesPlugin.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index 6b6f622a5a7..547071cc6af 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -84,6 +84,7 @@ class FilesPlugin extends ServerPlugin { public const SUBFOLDER_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-folder-count'; public const SUBFILE_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-file-count'; public const FILE_METADATA_SIZE = '{http://nextcloud.org/ns}file-metadata-size'; + public const FILE_METADATA_GPS = '{http://nextcloud.org/ns}file-metadata-gps'; /** Reference to main server object */ private ?Server $server = null; @@ -438,6 +439,27 @@ class FilesPlugin extends ServerPlugin { return $sizeMetadata->getValue(); }); + + $propFind->handle(self::FILE_METADATA_GPS, function () use ($node) { + if (!str_starts_with($node->getFileInfo()->getMimetype(), 'image')) { + return json_encode((object)[], JSON_THROW_ON_ERROR); + } + + if ($node->hasMetadata('gps')) { + $gpsMetadata = $node->getMetadata('gps'); + } else { + // This code path should not be called since we try to preload + // the metadata when loading the folder or the search results + // in one go + $metadataManager = \OC::$server->get(IMetadataManager::class); + $gpsMetadata = $metadataManager->fetchMetadataFor('gps', [$node->getId()])[$node->getId()]; + + // TODO would be nice to display this in the profiler... + \OC::$server->get(LoggerInterface::class)->debug('Inefficient fetching of metadata'); + } + + return $gpsMetadata->getValue(); + }); } } |