blob: 3ac6601d5dce499ab109192b73e1dc06b871527a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?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');
}
}
|