Skip to content

Commit af5c35f

Browse files
expose gps data via webdav
1 parent 78856f3 commit af5c35f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

apps/dav/lib/Connector/Sabre/FilesPlugin.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class FilesPlugin extends ServerPlugin {
8484
public const SUBFOLDER_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-folder-count';
8585
public const SUBFILE_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-file-count';
8686
public const FILE_METADATA_SIZE = '{http://nextcloud.org/ns}file-metadata-size';
87+
public const FILE_METADATA_GPS = '{http://nextcloud.org/ns}file-metadata-gps';
8788

8889
/** Reference to main server object */
8990
private ?Server $server = null;
@@ -438,6 +439,27 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
438439

439440
return $sizeMetadata->getValue();
440441
});
442+
443+
$propFind->handle(self::FILE_METADATA_GPS, function () use ($node) {
444+
if (!str_starts_with($node->getFileInfo()->getMimetype(), 'image')) {
445+
return json_encode((object)[], JSON_THROW_ON_ERROR);
446+
}
447+
448+
if ($node->hasMetadata('gps')) {
449+
$gpsMetadata = $node->getMetadata('gps');
450+
} else {
451+
// This code path should not be called since we try to preload
452+
// the metadata when loading the folder or the search results
453+
// in one go
454+
$metadataManager = \OC::$server->get(IMetadataManager::class);
455+
$gpsMetadata = $metadataManager->fetchMetadataFor('gps', [$node->getId()])[$node->getId()];
456+
457+
// TODO would be nice to display this in the profiler...
458+
\OC::$server->get(LoggerInterface::class)->debug('Inefficient fetching of metadata');
459+
}
460+
461+
return $gpsMetadata->getValue();
462+
});
441463
}
442464
}
443465

0 commit comments

Comments
 (0)