• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 22047397566

16 Feb 2026 01:47AM UTC coverage: 51.605%. First build
22047397566

Pull #6891

github

web-flow
Merge cc204601c into bdac9dc51
Pull Request #6891: feat: add id doc approver workflow

171 of 424 new or added lines in 24 files covered. (40.33%)

9145 of 17721 relevant lines covered (51.61%)

6.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

4.0
/lib/Service/UuidResolverService.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
7
 * SPDX-License-Identifier: AGPL-3.0-or-later
8
 */
9

10
namespace OCA\Libresign\Service;
11

12
use OCA\Libresign\Db\File;
13
use OCA\Libresign\Db\IdDocsMapper;
14
use OCA\Libresign\Db\SignRequest;
15
use OCA\Libresign\Exception\LibresignException;
16
use OCP\AppFramework\Db\DoesNotExistException;
17
use OCP\IUser;
18

19
class UuidResolverService {
20
        public function __construct(
21
                private SignFileService $signFileService,
22
                private IdDocsMapper $idDocsMapper,
23
                private IdDocsPolicyService $idDocsPolicyService,
24
        ) {
25
        }
55✔
26

27
        /**
28
         * Resolve UUID for a user, supporting both SignRequest and id-doc File
29
         *
30
         * @param string $uuid The UUID to resolve
31
         * @param IUser|null $user The authenticating user
32
         * @return array{signRequest: SignRequest|null, file: File, type: string}
33
         *                                                                        - type: 'sign_request' or 'id_doc'
34
         *
35
         * @throws LibresignException If UUID is invalid or user lacks permission
36
         */
37
        public function resolveUuidForUser(string $uuid, ?IUser $user): array {
38
                try {
NEW
39
                        $signRequest = $this->signFileService->getSignRequestByUuid($uuid);
×
NEW
40
                        $file = $this->signFileService->getFile($signRequest->getFileId());
×
41

NEW
42
                        return [
×
NEW
43
                                'signRequest' => $signRequest,
×
NEW
44
                                'file' => $file,
×
NEW
45
                                'type' => 'sign_request',
×
NEW
46
                        ];
×
NEW
47
                } catch (DoesNotExistException|LibresignException) {
×
48
                }
49

50
                try {
NEW
51
                        $file = $this->signFileService->getFileByUuid($uuid);
×
52

53
                        try {
NEW
54
                                $this->idDocsMapper->getByFileId($file->getId());
×
NEW
55
                                if (!$user || !$this->idDocsPolicyService->canApproverSignIdDoc($user, $file->getId(), $file->getStatus())) {
×
NEW
56
                                        throw new LibresignException('User is not authorized to access this identification document');
×
57
                                }
58

NEW
59
                                return [
×
NEW
60
                                        'signRequest' => null,
×
NEW
61
                                        'file' => $file,
×
NEW
62
                                        'type' => 'id_doc',
×
NEW
63
                                ];
×
NEW
64
                        } catch (DoesNotExistException) {
×
NEW
65
                                throw new LibresignException('File is not an identification document');
×
66
                        }
NEW
67
                } catch (DoesNotExistException|LibresignException $e) {
×
NEW
68
                        if ($e->getMessage() === 'File is not an identification document'
×
NEW
69
                                || $e->getMessage() === 'User is not authorized to access this identification document') {
×
NEW
70
                                throw $e;
×
71
                        }
72
                }
73

NEW
74
                throw new LibresignException('Invalid UUID');
×
75
        }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc