Skip to content

Commit fde3c2a

Browse files
committed
fix: use file id for signer cleanup
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 9e8f6d4 commit fde3c2a

5 files changed

Lines changed: 15 additions & 17 deletions

File tree

lib/Db/SignRequestMapper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,8 @@ public function getByFileIdAndSignRequestId(int $fileId, int $signRequestId): Si
412412

413413
$qb->select('sr.*')
414414
->from($this->getTableName(), 'sr')
415-
->join('sr', 'libresign_file', 'f', 'sr.file_id = f.id')
416415
->where(
417-
$qb->expr()->eq('f.node_id', $qb->createNamedParameter($fileId))
416+
$qb->expr()->eq('sr.file_id', $qb->createNamedParameter($fileId))
418417
)
419418
->andWhere(
420419
$qb->expr()->eq('sr.id', $qb->createNamedParameter($signRequestId))

lib/Service/RequestSignatureService.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,16 +556,16 @@ public function validateUsers(array $data): void {
556556

557557
public function unassociateToUser(int $fileId, int $signRequestId): void {
558558
$file = $this->fileMapper->getById($fileId);
559-
$signRequest = $this->signRequestMapper->getByFileIdAndSignRequestId($file->getNodeId(), $signRequestId);
559+
$signRequest = $this->signRequestMapper->getByFileIdAndSignRequestId($fileId, $signRequestId);
560560
$deletedOrder = $signRequest->getSigningOrder();
561561
$groupedIdentifyMethods = $this->identifyMethod->getIdentifyMethodsFromSignRequestId($signRequestId);
562562

563-
$this->dispatchCancellationEventIfNeeded($signRequest, $file->getNodeId(), $groupedIdentifyMethods);
563+
$this->dispatchCancellationEventIfNeeded($signRequest, $file, $groupedIdentifyMethods);
564564

565565
try {
566566
$this->signRequestMapper->delete($signRequest);
567567
$this->identifyMethod->deleteBySignRequestId($signRequestId);
568-
$visibleElements = $this->fileElementMapper->getByFileIdAndSignRequestId($file->getId(), $signRequestId);
568+
$visibleElements = $this->fileElementMapper->getByFileIdAndSignRequestId($fileId, $signRequestId);
569569
foreach ($visibleElements as $visibleElement) {
570570
$this->fileElementMapper->delete($visibleElement);
571571
}
@@ -610,20 +610,19 @@ private function propagateSignerDeletionToChildren(FileEntity $envelope, SignReq
610610

611611
private function dispatchCancellationEventIfNeeded(
612612
SignRequestEntity $signRequest,
613-
int $fileId,
613+
FileEntity $file,
614614
array $groupedIdentifyMethods,
615615
): void {
616616
if ($signRequest->getStatus() !== \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN->value) {
617617
return;
618618
}
619619

620620
try {
621-
$libreSignFile = $this->fileMapper->getByNodeId($fileId);
622621
foreach ($groupedIdentifyMethods as $identifyMethods) {
623622
foreach ($identifyMethods as $identifyMethod) {
624623
$event = new SignRequestCanceledEvent(
625624
$signRequest,
626-
$libreSignFile,
625+
$file,
627626
$identifyMethod,
628627
);
629628
$this->eventDispatcher->dispatchTyped($event);

tests/integration/features/file/list.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ Feature: file-list
2626
| (jq).ocs.data.data[0].signers[1].me | false |
2727
| (jq).ocs.data.data[0].signers[0].identifyMethods\|length | 1 |
2828
| (jq).ocs.data.data[0].signers[1].identifyMethods[0].method | account |
29-
When fetch field "(NODE_ID)ocs.data.data.0.nodeId" from previous JSON response
29+
When fetch field "(FILE_ID)ocs.data.data.0.id" from previous JSON response
3030
And fetch field "(SIGN_REQUEST_ID)ocs.data.data.0.signers.0.signRequestId" from previous JSON response
31-
And sending "delete" to ocs "/apps/libresign/api/v1/sign/file_id/<NODE_ID>/<SIGN_REQUEST_ID>"
31+
And sending "delete" to ocs "/apps/libresign/api/v1/sign/file_id/<FILE_ID>/<SIGN_REQUEST_ID>"
3232
And sending "get" to ocs "/apps/libresign/api/v1/file/list"
3333
Then the response should be a JSON array with the following mandatory values
3434
| key | value |

tests/integration/features/notification/custom_message_notification.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Feature: Custom message for signers
4747
| name | Document for email with description |
4848
| users | [{"identify":{"email":"external@domain.test"},"displayName":"External Signer","description":"Urgent: Please sign by end of day."}] |
4949
And the response should have a status code 200
50-
And fetch field "(FILE_ID)ocs.data.data.nodeId" from previous JSON response
50+
And fetch field "(FILE_ID)ocs.data.data.id" from previous JSON response
5151
And fetch field "(SIGN_REQUEST_ID)ocs.data.data.signers.0.signRequestId" from previous JSON response
5252
And my inbox is empty
5353
When sending "post" to ocs "/apps/libresign/api/v1/notify/signer"

tests/integration/features/sign/cancel.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Feature: sign-request-cancel
1010
| name | document |
1111
And the response should have a status code 200
1212
And sending "get" to ocs "/apps/libresign/api/v1/file/list"
13-
And fetch field "(NODE_ID)ocs.data.data.0.nodeId" from previous JSON response
13+
And fetch field "(FILE_ID)ocs.data.data.0.id" from previous JSON response
1414
And fetch field "(SIGN_REQUEST_ID)ocs.data.data.0.signers.0.signRequestId" from previous JSON response
15-
When sending "delete" to ocs "/apps/libresign/api/v1/sign/file_id/<NODE_ID>/<SIGN_REQUEST_ID>"
15+
When sending "delete" to ocs "/apps/libresign/api/v1/sign/file_id/<FILE_ID>/<SIGN_REQUEST_ID>"
1616
Then the response should have a status code 200
1717
When as user "signer1"
1818
And sending "get" to ocs "/apps/notifications/api/v2/notifications"
@@ -32,9 +32,9 @@ Feature: sign-request-cancel
3232
| status | 0 |
3333
And the response should have a status code 200
3434
When sending "get" to ocs "/apps/libresign/api/v1/file/list"
35-
And fetch field "(NODE_ID)ocs.data.data.0.nodeId" from previous JSON response
35+
And fetch field "(FILE_ID)ocs.data.data.0.id" from previous JSON response
3636
And fetch field "(SIGN_REQUEST_ID)ocs.data.data.0.signers.0.signRequestId" from previous JSON response
37-
And sending "delete" to ocs "/apps/libresign/api/v1/sign/file_id/<NODE_ID>/<SIGN_REQUEST_ID>"
37+
And sending "delete" to ocs "/apps/libresign/api/v1/sign/file_id/<FILE_ID>/<SIGN_REQUEST_ID>"
3838
Then the response should have a status code 200
3939
When as user "signer1"
4040
And sending "get" to ocs "/apps/notifications/api/v2/notifications"
@@ -51,9 +51,9 @@ Feature: sign-request-cancel
5151
| users | [{"identify":{"account":"signer1"}}] |
5252
| name | document |
5353
When sending "get" to ocs "/apps/libresign/api/v1/file/list"
54-
And fetch field "(NODE_ID)ocs.data.data.0.nodeId" from previous JSON response
54+
And fetch field "(FILE_ID)ocs.data.data.0.id" from previous JSON response
5555
And fetch field "(SIGN_REQUEST_ID)ocs.data.data.0.signers.0.signRequestId" from previous JSON response
56-
And sending "delete" to ocs "/apps/libresign/api/v1/sign/file_id/<NODE_ID>/<SIGN_REQUEST_ID>"
56+
And sending "delete" to ocs "/apps/libresign/api/v1/sign/file_id/<FILE_ID>/<SIGN_REQUEST_ID>"
5757
And sending "get" to ocs "/apps/libresign/api/v1/file/list"
5858
Then the response should be a JSON array with the following mandatory values
5959
| key | value |

0 commit comments

Comments
 (0)