0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-02-22 16:09:14 +00:00
nextcloud_server/apps/files/lib/Service/LivePhotosService.php
Andy Scherzinger 5b7dcc1427
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-05-29 08:58:16 +02:00

36 lines
817 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Files\Service;
use OCP\FilesMetadata\Exceptions\FilesMetadataNotFoundException;
use OCP\FilesMetadata\IFilesMetadataManager;
class LivePhotosService {
public function __construct(
private IFilesMetadataManager $filesMetadataManager,
) {
}
/**
* Get the associated live photo for a given file id
*/
public function getLivePhotoPeerId(int $fileId): ?int {
try {
$metadata = $this->filesMetadataManager->getMetadata($fileId);
} catch (FilesMetadataNotFoundException $ex) {
return null;
}
if (!$metadata->hasKey('files-live-photo')) {
return null;
}
return (int)$metadata->getString('files-live-photo');
}
}