Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
14 / 14 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| SendSignNotificationEvent | |
100.00% |
14 / 14 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| getDeliveryEventId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getLibreSignFile | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSignRequest | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getIdentifyMethod | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 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\Events; |
| 10 | |
| 11 | use OCA\Libresign\Db\File as FileEntity; |
| 12 | use OCA\Libresign\Db\SignRequest; |
| 13 | use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod; |
| 14 | use OCP\EventDispatcher\Event; |
| 15 | |
| 16 | class SendSignNotificationEvent extends Event { |
| 17 | public const FILE_TO_SIGN = 'libresign_file_to_sign'; |
| 18 | private string $deliveryEventId; |
| 19 | |
| 20 | public function __construct( |
| 21 | private SignRequest $signRequest, |
| 22 | private FileEntity $libreSignFile, |
| 23 | private IIdentifyMethod $identifyMethod, |
| 24 | ?string $deliveryEventId = null, |
| 25 | ) { |
| 26 | // Re-dispatching the same persisted business state is not a new |
| 27 | // delivery. Reminder invocations pass a period-specific event ID. |
| 28 | // Metadata is mutable and often includes unrelated channel activity; |
| 29 | // it must never change the identity of the same logical mail event. |
| 30 | // Explicit manual notices and periodic reminders supply their own IDs. |
| 31 | $this->deliveryEventId = $deliveryEventId ?? hash('sha256', json_encode([ |
| 32 | 'file' => $this->libreSignFile->getUuid(), |
| 33 | 'request' => $this->signRequest->getUuid(), |
| 34 | 'requestId' => $this->signRequest->getId(), |
| 35 | 'role' => $this->signRequest->getParticipantRole(), |
| 36 | 'status' => $this->signRequest->getStatus(), |
| 37 | 'order' => $this->signRequest->getSigningOrder(), |
| 38 | 'name' => $this->signRequest->getDisplayName(), |
| 39 | 'description' => $this->signRequest->getDescription(), |
| 40 | ], JSON_THROW_ON_ERROR)); |
| 41 | } |
| 42 | |
| 43 | public function getDeliveryEventId(): string { |
| 44 | return $this->deliveryEventId; |
| 45 | } |
| 46 | |
| 47 | public function getLibreSignFile(): FileEntity { |
| 48 | return $this->libreSignFile; |
| 49 | } |
| 50 | |
| 51 | public function getSignRequest(): SignRequest { |
| 52 | return $this->signRequest; |
| 53 | } |
| 54 | |
| 55 | public function getIdentifyMethod(): IIdentifyMethod { |
| 56 | return $this->identifyMethod; |
| 57 | } |
| 58 | } |