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

LibreSign / libresign / 20472217448

23 Dec 2025 09:41PM UTC coverage: 42.655%. First build
20472217448

Pull #6242

github

web-flow
Merge 5e8e97740 into 4f1a71d46
Pull Request #6242: feat: envelope support

301 of 1003 new or added lines in 21 files covered. (30.01%)

6159 of 14439 relevant lines covered (42.66%)

4.97 hits per line

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

45.45
/lib/Controller/LibresignTrait.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Controller;
10

11
use OC\AppFramework\Http as AppFrameworkHttp;
12
use OCA\Libresign\Db\File as FileEntity;
13
use OCA\Libresign\Db\SignRequest as SignRequestEntity;
14
use OCA\Libresign\Exception\LibresignException;
15
use OCA\Libresign\Helper\JSActions;
16
use OCA\Libresign\Service\SignFileService;
17
use OCP\AppFramework\Db\DoesNotExistException;
18
use OCP\Files\File;
19
use OCP\IL10N;
20
use OCP\IUserSession;
21

22
trait LibresignTrait {
23
        protected SignFileService $signFileService;
24
        protected IL10N $l10n;
25
        protected IUserSession $userSession;
26
        private ?SignRequestEntity $signRequestEntity = null;
27
        private ?FileEntity $fileEntity = null;
28

29
        /**
30
         * @throws LibresignException
31
         */
32
        private function loadEntitiesFromUuid(string $uuid): void {
33
                if ($this->signRequestEntity instanceof SignRequestEntity
2✔
34
                        && $this->fileEntity instanceof FileEntity) {
2✔
35
                        return;
×
36
                }
37
                try {
38
                        $this->signRequestEntity = $this->signFileService->getSignRequestByUuid($uuid);
2✔
39
                        $this->fileEntity = $this->signFileService->getFile(
×
40
                                $this->signRequestEntity->getFileId(),
×
41
                        );
×
42
                } catch (DoesNotExistException|LibresignException) {
2✔
43
                        throw new LibresignException(json_encode([
2✔
44
                                'action' => JSActions::ACTION_DO_NOTHING,
2✔
45
                                'errors' => [['message' => $this->l10n->t('Invalid UUID')]],
2✔
46
                        ]), AppFrameworkHttp::STATUS_NOT_FOUND);
2✔
47
                }
48
        }
49

50
        /**
51
         * @throws LibresignException
52
         */
53
        public function validateSignRequestUuid(string $uuid): void {
54
                $this->loadEntitiesFromUuid($uuid);
1✔
55
                $this->signFileService->validateSigner($uuid, $this->userSession->getUser());
×
56
        }
57

58
        /**
59
         * @throws LibresignException
60
         */
61
        public function validateRenewSigner(string $uuid): void {
62
                $this->loadEntitiesFromUuid($uuid);
×
63
                $this->signFileService->validateRenewSigner($uuid, $this->userSession->getUser());
×
64
        }
65

66
        /**
67
         * @throws LibresignException
68
         */
69
        public function loadNextcloudFileFromSignRequestUuid(string $uuid): void {
70
                $this->loadEntitiesFromUuid($uuid);
1✔
71
        }
72

73
        public function getSignRequestEntity(): ?SignRequestEntity {
74
                return $this->signRequestEntity;
×
75
        }
76

77
        public function getFileEntity(): ?FileEntity {
78
                return $this->fileEntity;
×
79
        }
80

81
        /**
82
         * @return File[] Array of files, empty if no file entity loaded
83
         */
84
        public function getNextcloudFiles(): array {
NEW
85
                if (!$this->fileEntity) {
×
NEW
86
                        return [];
×
87
                }
88

NEW
89
                return $this->signFileService->getNextcloudFiles($this->fileEntity);
×
90
        }
91
}
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