Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
12 / 16 |
|
33.33% |
2 / 6 |
CRAP | |
0.00% |
0 / 1 |
| FileSigned | |
75.00% |
12 / 16 |
|
33.33% |
2 / 6 |
11.56 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getIdentifier | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPriority | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| canChangeNotification | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |||
| canChangeMail | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | /** |
| 5 | * SPDX-FileCopyrightText: 2025 LibreCode coop and contributors |
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | */ |
| 8 | |
| 9 | namespace OCA\Libresign\Activity\Settings; |
| 10 | |
| 11 | use OCA\Libresign\Events\SignedEvent; |
| 12 | use OCA\Libresign\Exception\LibresignException; |
| 13 | use OCA\Libresign\Service\Validation\SigningRequestValidator; |
| 14 | use OCP\IL10N; |
| 15 | use OCP\IUser; |
| 16 | use OCP\IUserSession; |
| 17 | |
| 18 | class FileSigned extends LibresignActivitySettings { |
| 19 | public function __construct( |
| 20 | protected IL10N $l, |
| 21 | protected SigningRequestValidator $signingRequestValidator, |
| 22 | protected IUserSession $userSession, |
| 23 | ) { |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * {@inheritdoc} |
| 28 | */ |
| 29 | #[\Override] |
| 30 | public function getIdentifier(): string { |
| 31 | return SignedEvent::FILE_SIGNED; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * {@inheritdoc} |
| 36 | */ |
| 37 | #[\Override] |
| 38 | public function getName(): string { |
| 39 | // TRANSLATORS Activity app setting label for LibreSign events when a document finishes being digitally signed. Keep the <strong> markup. |
| 40 | return $this->l->t('A document has been <strong>signed</strong>'); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * {@inheritdoc} |
| 45 | */ |
| 46 | #[\Override] |
| 47 | public function getPriority(): int { |
| 48 | return 52; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * {@inheritdoc} |
| 53 | */ |
| 54 | #[\Override] |
| 55 | public function canChangeNotification(): bool { |
| 56 | if (!$this->userSession->getUser() instanceof IUser) { |
| 57 | return true; |
| 58 | } |
| 59 | try { |
| 60 | $this->signingRequestValidator->canRequestSign($this->userSession->getUser()); |
| 61 | } catch (LibresignException) { |
| 62 | return false; |
| 63 | } |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * {@inheritdoc} |
| 69 | */ |
| 70 | #[\Override] |
| 71 | public function canChangeMail() { |
| 72 | if (!$this->userSession->getUser() instanceof IUser) { |
| 73 | return true; |
| 74 | } |
| 75 | try { |
| 76 | $this->signingRequestValidator->canRequestSign($this->userSession->getUser()); |
| 77 | } catch (LibresignException) { |
| 78 | return false; |
| 79 | } |
| 80 | return true; |
| 81 | } |
| 82 | } |