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

LibreSign / libresign / 20210417471

14 Dec 2025 03:51PM UTC coverage: 44.081%. First build
20210417471

Pull #6181

github

web-flow
Merge 21aee754a into 95a26cb92
Pull Request #6181: feat: cancel signature request notification

114 of 235 new or added lines in 9 files covered. (48.51%)

5932 of 13457 relevant lines covered (44.08%)

5.06 hits per line

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

77.01
/lib/Service/RequestSignatureService.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\Service;
10

11
use OCA\Libresign\AppInfo\Application;
12
use OCA\Libresign\Db\File as FileEntity;
13
use OCA\Libresign\Db\FileElementMapper;
14
use OCA\Libresign\Db\FileMapper;
15
use OCA\Libresign\Db\IdentifyMethodMapper;
16
use OCA\Libresign\Db\SignRequest as SignRequestEntity;
17
use OCA\Libresign\Db\SignRequestMapper;
18
use OCA\Libresign\Enum\SignatureFlow;
19
use OCA\Libresign\Events\SignRequestCanceledEvent;
20
use OCA\Libresign\Handler\DocMdpHandler;
21
use OCA\Libresign\Helper\ValidateHelper;
22
use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod;
23
use OCP\AppFramework\Db\DoesNotExistException;
24
use OCP\EventDispatcher\IEventDispatcher;
25
use OCP\Files\IMimeTypeDetector;
26
use OCP\Files\Node;
27
use OCP\Http\Client\IClientService;
28
use OCP\IAppConfig;
29
use OCP\IL10N;
30
use OCP\IUser;
31
use OCP\IUserManager;
32
use Psr\Log\LoggerInterface;
33
use Sabre\DAV\UUIDUtil;
34

35
class RequestSignatureService {
36
        use TFile;
37

38
        public function __construct(
39
                protected IL10N $l10n,
40
                protected IdentifyMethodService $identifyMethod,
41
                protected SignRequestMapper $signRequestMapper,
42
                protected IUserManager $userManager,
43
                protected FileMapper $fileMapper,
44
                protected IdentifyMethodMapper $identifyMethodMapper,
45
                protected PdfParserService $pdfParserService,
46
                protected FileElementService $fileElementService,
47
                protected FileElementMapper $fileElementMapper,
48
                protected FolderService $folderService,
49
                protected IMimeTypeDetector $mimeTypeDetector,
50
                protected ValidateHelper $validateHelper,
51
                protected IClientService $client,
52
                protected DocMdpHandler $docMdpHandler,
53
                protected LoggerInterface $logger,
54
                protected SequentialSigningService $sequentialSigningService,
55
                protected IAppConfig $appConfig,
56
                protected IEventDispatcher $eventDispatcher,
57
        ) {
58
        }
56✔
59

60
        public function save(array $data): FileEntity {
61
                $file = $this->saveFile($data);
14✔
62
                $this->saveVisibleElements($data, $file);
14✔
63
                if (!isset($data['status'])) {
14✔
64
                        $data['status'] = $file->getStatus();
12✔
65
                }
66
                $this->sequentialSigningService->setFile($file);
14✔
67
                $this->associateToSigners($data, $file->getId());
14✔
68
                return $file;
14✔
69
        }
70

71
        /**
72
         * Save file data
73
         *
74
         * @param array{?userManager: IUser, ?signRequest: SignRequest, name: string, callback: string, uuid?: ?string, status: int, file?: array{fileId?: int, fileNode?: Node}} $data
75
         */
76
        public function saveFile(array $data): FileEntity {
77
                if (!empty($data['uuid'])) {
15✔
78
                        $file = $this->fileMapper->getByUuid($data['uuid']);
1✔
79
                        return $this->updateStatus($file, $data['status'] ?? 0);
1✔
80
                }
81
                $fileId = null;
15✔
82
                if (isset($data['file']['fileNode']) && $data['file']['fileNode'] instanceof Node) {
15✔
83
                        $fileId = $data['file']['fileNode']->getId();
1✔
84
                } elseif (!empty($data['file']['fileId'])) {
14✔
85
                        $fileId = $data['file']['fileId'];
×
86
                }
87
                if (!is_null($fileId)) {
15✔
88
                        try {
89
                                $file = $this->fileMapper->getByFileId($fileId);
1✔
90
                                return $this->updateStatus($file, $data['status'] ?? 0);
×
91
                        } catch (\Throwable) {
1✔
92
                        }
93
                }
94

95
                $node = $this->getNodeFromData($data);
15✔
96

97
                $file = new FileEntity();
15✔
98
                $file->setNodeId($node->getId());
15✔
99
                if ($data['userManager'] instanceof IUser) {
15✔
100
                        $file->setUserId($data['userManager']->getUID());
15✔
101
                } elseif ($data['signRequest'] instanceof SignRequestEntity) {
×
102
                        $file->setSignRequestId($data['signRequest']->getId());
×
103
                }
104
                $file->setUuid(UUIDUtil::getUUID());
15✔
105
                $file->setCreatedAt(new \DateTime('now', new \DateTimeZone('UTC')));
15✔
106
                $metadata = $this->getFileMetadata($node);
15✔
107
                $file->setName($this->removeExtensionFromName($data['name'], $metadata));
15✔
108
                $file->setMetadata($metadata);
15✔
109
                if (!empty($data['callback'])) {
15✔
110
                        $file->setCallback($data['callback']);
×
111
                }
112
                if (isset($data['status'])) {
15✔
113
                        $file->setStatus($data['status']);
2✔
114
                } else {
115
                        $file->setStatus(FileEntity::STATUS_ABLE_TO_SIGN);
13✔
116
                }
117

118
                if (isset($data['signatureFlow']) && is_string($data['signatureFlow'])) {
15✔
119
                        try {
120
                                $signatureFlow = \OCA\Libresign\Enum\SignatureFlow::from($data['signatureFlow']);
×
121
                                $file->setSignatureFlowEnum($signatureFlow);
×
122
                        } catch (\ValueError) {
×
123
                                $this->setSignatureFlowFromGlobalConfig($file);
×
124
                        }
125
                } else {
126
                        $this->setSignatureFlowFromGlobalConfig($file);
15✔
127
                }
128

129
                $this->fileMapper->insert($file);
15✔
130
                return $file;
15✔
131
        }
132

133
        private function setSignatureFlowFromGlobalConfig(FileEntity $file): void {
134
                $globalFlowValue = $this->appConfig->getValueString(Application::APP_ID, 'signature_flow', SignatureFlow::PARALLEL->value);
15✔
135
                $globalFlow = SignatureFlow::from($globalFlowValue);
15✔
136
                $file->setSignatureFlowEnum($globalFlow);
15✔
137
        }
138

139
        private function updateStatus(FileEntity $file, int $status): FileEntity {
140
                if ($status > $file->getStatus()) {
1✔
141
                        $file->setStatus($status);
×
142
                        /** @var FileEntity */
143
                        return $this->fileMapper->update($file);
×
144
                }
145
                return $file;
1✔
146
        }
147

148
        private function getFileMetadata(\OCP\Files\Node $node): array {
149
                $metadata = [];
18✔
150
                if ($extension = strtolower($node->getExtension())) {
18✔
151
                        $metadata = [
17✔
152
                                'extension' => $extension,
17✔
153
                        ];
17✔
154
                        if ($metadata['extension'] === 'pdf') {
17✔
155
                                $metadata = array_merge(
16✔
156
                                        $metadata,
16✔
157
                                        $this->pdfParserService
16✔
158
                                                ->setFile($node)
16✔
159
                                                ->getPageDimensions()
16✔
160
                                );
16✔
161
                        }
162
                }
163
                return $metadata;
18✔
164
        }
165

166
        private function removeExtensionFromName(string $name, array $metadata): string {
167
                if (!isset($metadata['extension'])) {
15✔
168
                        return $name;
×
169
                }
170
                $extensionPattern = '/\.' . preg_quote($metadata['extension'], '/') . '$/i';
15✔
171
                $result = preg_replace($extensionPattern, '', $name);
15✔
172
                return $result ?? $name;
15✔
173
        }
174

175
        private function deleteIdentifyMethodIfNotExits(array $users, int $fileId): void {
176
                $file = $this->fileMapper->getById($fileId);
13✔
177
                $signRequests = $this->signRequestMapper->getByFileId($fileId);
13✔
178
                foreach ($signRequests as $key => $signRequest) {
13✔
179
                        $identifyMethods = $this->identifyMethod->getIdentifyMethodsFromSignRequestId($signRequest->getId());
1✔
180
                        if (empty($identifyMethods)) {
1✔
181
                                $this->unassociateToUser($file->getNodeId(), $signRequest->getId());
×
182
                                continue;
×
183
                        }
184
                        foreach ($identifyMethods as $methodName => $list) {
1✔
185
                                foreach ($list as $method) {
1✔
186
                                        $exists[$key]['identify'][$methodName] = $method->getEntity()->getIdentifierValue();
1✔
187
                                        if (!$this->identifyMethodExists($users, $method)) {
1✔
188
                                                $this->unassociateToUser($file->getNodeId(), $signRequest->getId());
1✔
189
                                                continue 3;
1✔
190
                                        }
191
                                }
192
                        }
193
                }
194
        }
195

196
        private function identifyMethodExists(array $users, IIdentifyMethod $identifyMethod): bool {
197
                foreach ($users as $user) {
1✔
198
                        if (!empty($user['identifyMethods'])) {
1✔
199
                                foreach ($user['identifyMethods'] as $data) {
×
200
                                        if ($identifyMethod->getEntity()->getIdentifierKey() !== $data['method']) {
×
201
                                                continue;
×
202
                                        }
203
                                        if ($identifyMethod->getEntity()->getIdentifierValue() === $data['value']) {
×
204
                                                return true;
×
205
                                        }
206
                                }
207
                        } else {
208
                                foreach ($user['identify'] as $method => $value) {
1✔
209
                                        if ($identifyMethod->getEntity()->getIdentifierKey() !== $method) {
1✔
210
                                                continue;
×
211
                                        }
212
                                        if ($identifyMethod->getEntity()->getIdentifierValue() === $value) {
1✔
213
                                                return true;
×
214
                                        }
215
                                }
216
                        }
217
                }
218
                return false;
1✔
219
        }
220

221
        /**
222
         * @return SignRequestEntity[]
223
         *
224
         * @psalm-return list<SignRequestEntity>
225
         */
226
        private function associateToSigners(array $data, int $fileId): array {
227
                $return = [];
14✔
228
                if (!empty($data['users'])) {
14✔
229
                        $this->deleteIdentifyMethodIfNotExits($data['users'], $fileId);
13✔
230

231
                        $this->sequentialSigningService->resetOrderCounter();
13✔
232
                        $fileStatus = $data['status'] ?? null;
13✔
233

234
                        foreach ($data['users'] as $user) {
13✔
235
                                $userProvidedOrder = isset($user['signingOrder']) ? (int)$user['signingOrder'] : null;
13✔
236
                                $signingOrder = $this->sequentialSigningService->determineSigningOrder($userProvidedOrder);
13✔
237
                                $signerStatus = $user['status'] ?? null;
13✔
238

239
                                if (isset($user['identifyMethods'])) {
13✔
240
                                        foreach ($user['identifyMethods'] as $identifyMethod) {
×
241
                                                $return[] = $this->associateToSigner(
×
242
                                                        identifyMethods: [
×
243
                                                                $identifyMethod['method'] => $identifyMethod['value'],
×
244
                                                        ],
×
245
                                                        displayName: $user['displayName'] ?? '',
×
246
                                                        description: $user['description'] ?? '',
×
247
                                                        notify: empty($user['notify']) && $this->isStatusAbleToNotify($fileStatus),
×
248
                                                        fileId: $fileId,
×
249
                                                        signingOrder: $signingOrder,
×
250
                                                        fileStatus: $fileStatus,
×
251
                                                        signerStatus: $signerStatus,
×
252
                                                );
×
253
                                        }
254
                                } else {
255
                                        $return[] = $this->associateToSigner(
13✔
256
                                                identifyMethods: $user['identify'],
13✔
257
                                                displayName: $user['displayName'] ?? '',
13✔
258
                                                description: $user['description'] ?? '',
13✔
259
                                                notify: empty($user['notify']) && $this->isStatusAbleToNotify($fileStatus),
13✔
260
                                                fileId: $fileId,
13✔
261
                                                signingOrder: $signingOrder,
13✔
262
                                                fileStatus: $fileStatus,
13✔
263
                                                signerStatus: $signerStatus,
13✔
264
                                        );
13✔
265
                                }
266
                        }
267
                }
268
                return $return;
14✔
269
        }
270

271
        private function isStatusAbleToNotify(?int $status): bool {
272
                return in_array($status, [
13✔
273
                        FileEntity::STATUS_ABLE_TO_SIGN,
13✔
274
                        FileEntity::STATUS_PARTIAL_SIGNED,
13✔
275
                ]);
13✔
276
        }
277

278
        private function associateToSigner(
279
                array $identifyMethods,
280
                string $displayName,
281
                string $description,
282
                bool $notify,
283
                int $fileId,
284
                int $signingOrder = 0,
285
                ?int $fileStatus = null,
286
                ?int $signerStatus = null,
287
        ): SignRequestEntity {
288
                $identifyMethodsIncances = $this->identifyMethod->getByUserData($identifyMethods);
13✔
289
                if (empty($identifyMethodsIncances)) {
13✔
290
                        throw new \Exception($this->l10n->t('Invalid identification method'));
×
291
                }
292
                $signRequest = $this->getSignRequestByIdentifyMethod(
13✔
293
                        current($identifyMethodsIncances),
13✔
294
                        $fileId
13✔
295
                );
13✔
296
                $displayName = $this->getDisplayNameFromIdentifyMethodIfEmpty($identifyMethodsIncances, $displayName);
13✔
297
                $this->setDataToUser($signRequest, $displayName, $description, $fileId);
13✔
298

299
                $signRequest->setSigningOrder($signingOrder);
13✔
300

301
                $isNewSignRequest = !$signRequest->getId();
13✔
302
                $currentStatus = $signRequest->getStatusEnum();
13✔
303

304
                if ($isNewSignRequest || $currentStatus === \OCA\Libresign\Enum\SignRequestStatus::DRAFT) {
13✔
305
                        $desiredStatus = $this->determineInitialStatus($signingOrder, $fileStatus, $signerStatus, $currentStatus, $fileId);
13✔
306
                        $this->updateStatusIfAllowed($signRequest, $currentStatus, $desiredStatus, $isNewSignRequest);
13✔
307
                }
308

309
                $this->saveSignRequest($signRequest);
13✔
310

311
                $shouldNotify = $notify && $signRequest->getStatusEnum() === \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN;
13✔
312

313
                foreach ($identifyMethodsIncances as $identifyMethod) {
13✔
314
                        $identifyMethod->getEntity()->setSignRequestId($signRequest->getId());
13✔
315
                        $identifyMethod->willNotifyUser($shouldNotify);
13✔
316
                        $identifyMethod->save();
13✔
317
                }
318
                return $signRequest;
13✔
319
        }
320

321
        private function updateStatusIfAllowed(
322
                SignRequestEntity $signRequest,
323
                \OCA\Libresign\Enum\SignRequestStatus $currentStatus,
324
                \OCA\Libresign\Enum\SignRequestStatus $desiredStatus,
325
                bool $isNewSignRequest,
326
        ): void {
327
                if ($isNewSignRequest || $this->sequentialSigningService->isStatusUpgrade($currentStatus, $desiredStatus)) {
13✔
328
                        $signRequest->setStatusEnum($desiredStatus);
13✔
329
                }
330
        }
331

332
        private function determineInitialStatus(
333
                int $signingOrder,
334
                ?int $fileStatus = null,
335
                ?int $signerStatus = null,
336
                ?\OCA\Libresign\Enum\SignRequestStatus $currentStatus = null,
337
                ?int $fileId = null,
338
        ): \OCA\Libresign\Enum\SignRequestStatus {
339
                // If fileStatus is explicitly DRAFT (0), keep signer as DRAFT
340
                // This allows adding new signers in DRAFT mode even when file is not in DRAFT status
341
                if ($fileStatus === FileEntity::STATUS_DRAFT) {
15✔
342
                        return \OCA\Libresign\Enum\SignRequestStatus::DRAFT;
×
343
                }
344

345
                // If file status is ABLE_TO_SIGN, apply flow-based logic
346
                if ($fileStatus === FileEntity::STATUS_ABLE_TO_SIGN) {
15✔
347
                        if ($this->sequentialSigningService->isOrderedNumericFlow()) {
15✔
348
                                // In ordered flow, only first signer (order 1) should be ABLE_TO_SIGN
349
                                // Others remain DRAFT until their turn
350
                                return $signingOrder === 1
1✔
351
                                        ? \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN
1✔
352
                                        : \OCA\Libresign\Enum\SignRequestStatus::DRAFT;
1✔
353
                        }
354
                        // In parallel flow, all can sign - ignore individual signer status if file is ABLE_TO_SIGN
355
                        return \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN;
14✔
356
                }
357

358
                // Handle explicit signer status when file status is not DRAFT or ABLE_TO_SIGN
359
                if ($signerStatus !== null) {
×
360
                        $desiredStatus = \OCA\Libresign\Enum\SignRequestStatus::from($signerStatus);
×
361
                        if ($currentStatus !== null && !$this->sequentialSigningService->isStatusUpgrade($currentStatus, $desiredStatus)) {
×
362
                                return $currentStatus;
×
363
                        }
364

365
                        // Validate status transition based on signing order
366
                        if ($fileId !== null) {
×
367
                                return $this->sequentialSigningService->validateStatusByOrder($desiredStatus, $signingOrder, $fileId);
×
368
                        }
369

370
                        return $desiredStatus;
×
371
                }
372

373
                // Default fallback based on flow type
374
                if (!$this->sequentialSigningService->isOrderedNumericFlow()) {
×
375
                        return \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN;
×
376
                }
377

378
                return $signingOrder === 1
×
379
                        ? \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN
×
380
                        : \OCA\Libresign\Enum\SignRequestStatus::DRAFT;
×
381
        }
382

383
        /**
384
         * @param IIdentifyMethod[] $identifyMethodsIncances
385
         * @param string $displayName
386
         * @return string
387
         */
388
        private function getDisplayNameFromIdentifyMethodIfEmpty(array $identifyMethodsIncances, string $displayName): string {
389
                if (!empty($displayName)) {
13✔
390
                        return $displayName;
×
391
                }
392
                foreach ($identifyMethodsIncances as $identifyMethod) {
13✔
393
                        if ($identifyMethod->getName() === 'account') {
13✔
394
                                return $this->userManager->get($identifyMethod->getEntity()->getIdentifierValue())->getDisplayName();
2✔
395
                        }
396
                }
397
                foreach ($identifyMethodsIncances as $identifyMethod) {
11✔
398
                        if ($identifyMethod->getName() !== 'account') {
11✔
399
                                return $identifyMethod->getEntity()->getIdentifierValue();
11✔
400
                        }
401
                }
402
                return '';
×
403
        }
404

405
        private function saveVisibleElements(array $data, FileEntity $file): array {
406
                if (empty($data['visibleElements'])) {
17✔
407
                        return [];
15✔
408
                }
409
                $elements = $data['visibleElements'];
2✔
410
                foreach ($elements as $key => $element) {
2✔
411
                        $element['fileId'] = $file->getId();
2✔
412
                        $elements[$key] = $this->fileElementService->saveVisibleElement($element);
2✔
413
                }
414
                return $elements;
2✔
415
        }
416

417
        public function validateNewRequestToFile(array $data): void {
418
                $this->validateNewFile($data);
7✔
419
                $this->validateUsers($data);
6✔
420
                $this->validateHelper->validateFileStatus($data);
2✔
421
        }
422

423
        public function validateNewFile(array $data): void {
424
                if (empty($data['name'])) {
7✔
425
                        throw new \Exception($this->l10n->t('Name is mandatory'));
1✔
426
                }
427
                $this->validateHelper->validateNewFile($data);
6✔
428
        }
429

430
        public function validateUsers(array $data): void {
431
                if (empty($data['users'])) {
6✔
432
                        throw new \Exception($this->l10n->t('Empty users list'));
3✔
433
                }
434
                if (!is_array($data['users'])) {
3✔
435
                        // TRANSLATION This message will be displayed when the request to API with the key users has a value that is not an array
436
                        throw new \Exception($this->l10n->t('User list needs to be an array'));
1✔
437
                }
438
                foreach ($data['users'] as $user) {
2✔
439
                        if (!array_key_exists('identify', $user)) {
2✔
440
                                throw new \Exception('Identify key not found');
×
441
                        }
442
                        $this->identifyMethod->setAllEntityData($user);
2✔
443
                }
444
        }
445

446
        public function saveSignRequest(SignRequestEntity $signRequest): void {
447
                if ($signRequest->getId()) {
15✔
448
                        $this->signRequestMapper->update($signRequest);
1✔
449
                } else {
450
                        $this->signRequestMapper->insert($signRequest);
14✔
451
                }
452
        }
453

454
        /**
455
         * @psalm-suppress MixedMethodCall
456
         */
457
        private function setDataToUser(SignRequestEntity $signRequest, string $displayName, string $description, int $fileId): void {
458
                $signRequest->setFileId($fileId);
13✔
459
                if (!$signRequest->getUuid()) {
13✔
460
                        $signRequest->setUuid(UUIDUtil::getUUID());
13✔
461
                }
462
                if (!empty($displayName)) {
13✔
463
                        $signRequest->setDisplayName($displayName);
13✔
464
                }
465
                if (!empty($description)) {
13✔
466
                        $signRequest->setDescription($description);
×
467
                }
468
                if (!$signRequest->getId()) {
13✔
469
                        $signRequest->setCreatedAt(new \DateTime('now', new \DateTimeZone('UTC')));
13✔
470
                }
471
        }
472

473
        private function getSignRequestByIdentifyMethod(IIdentifyMethod $identifyMethod, int $fileId): SignRequestEntity {
474
                try {
475
                        $signRequest = $this->signRequestMapper->getByIdentifyMethodAndFileId($identifyMethod, $fileId);
13✔
476
                } catch (DoesNotExistException) {
13✔
477
                        $signRequest = new SignRequestEntity();
13✔
478
                }
479
                return $signRequest;
13✔
480
        }
481

482
        public function unassociateToUser(int $fileId, int $signRequestId): void {
483
                $signRequest = $this->signRequestMapper->getByFileIdAndSignRequestId($fileId, $signRequestId);
2✔
484
                $deletedOrder = $signRequest->getSigningOrder();
2✔
485
                $groupedIdentifyMethods = $this->identifyMethod->getIdentifyMethodsFromSignRequestId($signRequestId);
2✔
486

487
                $this->dispatchCancellationEventIfNeeded($signRequest, $fileId, $groupedIdentifyMethods);
2✔
488

489
                try {
490
                        $this->signRequestMapper->delete($signRequest);
2✔
491
                        foreach ($groupedIdentifyMethods as $identifyMethods) {
2✔
492
                                foreach ($identifyMethods as $identifyMethod) {
2✔
493
                                        $identifyMethod->delete();
2✔
494
                                }
495
                        }
496
                        $visibleElements = $this->fileElementMapper->getByFileIdAndSignRequestId($fileId, $signRequestId);
2✔
497
                        foreach ($visibleElements as $visibleElement) {
2✔
498
                                $this->fileElementMapper->delete($visibleElement);
×
499
                        }
500

501
                        $this->sequentialSigningService->reorderAfterDeletion($fileId, $deletedOrder);
2✔
502
                } catch (\Throwable) {
×
503
                }
504
        }
505

506
        private function dispatchCancellationEventIfNeeded(
507
                SignRequestEntity $signRequest,
508
                int $fileId,
509
                array $groupedIdentifyMethods,
510
        ): void {
511
                if ($signRequest->getStatus() !== \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN->value) {
2✔
NEW
512
                        return;
×
513
                }
514

515
                try {
516
                        $libreSignFile = $this->fileMapper->getByFileId($fileId);
2✔
517
                        foreach ($groupedIdentifyMethods as $identifyMethods) {
2✔
518
                                foreach ($identifyMethods as $identifyMethod) {
2✔
519
                                        $event = new SignRequestCanceledEvent(
2✔
520
                                                $signRequest,
2✔
521
                                                $libreSignFile,
2✔
522
                                                $identifyMethod,
2✔
523
                                        );
2✔
524
                                        $this->eventDispatcher->dispatchTyped($event);
2✔
525
                                }
526
                        }
NEW
527
                } catch (\Throwable $e) {
×
NEW
528
                        $this->logger->error('Error dispatching SignRequestCanceledEvent: ' . $e->getMessage(), ['exception' => $e]);
×
529
                }
530
        }
531

532
        public function deleteRequestSignature(array $data): void {
533
                if (!empty($data['uuid'])) {
2✔
534
                        $signatures = $this->signRequestMapper->getByFileUuid($data['uuid']);
×
535
                        $fileData = $this->fileMapper->getByUuid($data['uuid']);
×
536
                } elseif (!empty($data['file']['fileId'])) {
2✔
537
                        $signatures = $this->signRequestMapper->getByNodeId($data['file']['fileId']);
2✔
538
                        $fileData = $this->fileMapper->getByFileId($data['file']['fileId']);
2✔
539
                } else {
540
                        throw new \Exception($this->l10n->t('Please provide either UUID or File object'));
×
541
                }
542
                foreach ($signatures as $signRequest) {
2✔
543
                        $this->signRequestMapper->delete($signRequest);
2✔
544
                }
545
                $this->fileMapper->delete($fileData);
2✔
546
                $this->fileElementService->deleteVisibleElements($fileData->getId());
2✔
547
        }
548
}
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