Skip to content

Commit 18f6689

Browse files
authored
Merge pull request #4849 from LibreSign/fix/only-notify-when-is-not-draft
fix: only notify when is not draft
2 parents 7893260 + bfb12d1 commit 18f6689

3 files changed

Lines changed: 38 additions & 5 deletions

File tree

lib/Service/RequestSignatureService.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public function __construct(
5050
public function save(array $data): FileEntity {
5151
$file = $this->saveFile($data);
5252
$this->saveVisibleElements($data, $file);
53+
if (empty($data['status'])) {
54+
$data['status'] = $file->getStatus();
55+
}
5356
$this->associateToSigners($data, $file->getId());
5457
return $file;
5558
}
@@ -190,7 +193,7 @@ private function associateToSigners(array $data, int $fileId): array {
190193
],
191194
displayName: $user['displayName'] ?? '',
192195
description: $user['description'] ?? '',
193-
notify: empty($user['notify']),
196+
notify: empty($user['notify']) && $this->isStatusAbleToNotify($data['status'] ?? null),
194197
fileId: $fileId,
195198
);
196199
}
@@ -199,7 +202,7 @@ private function associateToSigners(array $data, int $fileId): array {
199202
identifyMethods: $user['identify'],
200203
displayName: $user['displayName'] ?? '',
201204
description: $user['description'] ?? '',
202-
notify: empty($user['notify']),
205+
notify: empty($user['notify']) && $this->isStatusAbleToNotify($data['status'] ?? null),
203206
fileId: $fileId,
204207
);
205208
}
@@ -208,6 +211,13 @@ private function associateToSigners(array $data, int $fileId): array {
208211
return $return;
209212
}
210213

214+
private function isStatusAbleToNotify(?int $status): bool {
215+
return in_array($status, [
216+
FileEntity::STATUS_ABLE_TO_SIGN,
217+
FileEntity::STATUS_PARTIAL_SIGNED,
218+
]);
219+
}
220+
211221
private function associateToSigner(array $identifyMethods, string $displayName, string $description, bool $notify, int $fileId): SignRequestEntity {
212222
$identifyMethodsIncances = $this->identifyMethod->getByUserData($identifyMethods);
213223
if (empty($identifyMethodsIncances)) {

src/Components/RightSidebar/RequestSignatureTab.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ export default {
210210
const config = {
211211
url: generateOcsUrl('/apps/libresign/api/v1/request-signature'),
212212
data: {
213-
status: this.filesStore.getFile()?.status ?? 0,
214213
name: this.filesStore.getFile()?.name,
215214
users: [],
216215
},
@@ -230,9 +229,12 @@ export default {
230229
})
231230
config.data.users.push(user)
232231
})
233-
234-
if (!this.isSignElementsAvailable()) {
232+
if (this.filesStore.getFile()?.status) {
233+
config.data.status = this.filesStore.getFile()?.status
234+
} else if (!this.isSignElementsAvailable()) {
235235
config.data.status = 1
236+
} else {
237+
config.data.status = 0
236238
}
237239
238240
if (this.filesStore.getFile().uuid) {

tests/integration/features/sign/request.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,24 @@ Feature: request-signature
448448
| (jq).ocs.data.data[0].signers\|length | 1 |
449449
| (jq).ocs.data.data[0].signers[0].email | signer1@domain.test |
450450
| (jq).ocs.data.data[0].signers[0].me | false |
451+
452+
Scenario: Not notify with status 0 and notify with status 1
453+
Given run the command "libresign:configure:openssl --cn test" with result code 0
454+
And user "signer1" exists
455+
And set the email of user "signer1" to "signer1@domain.test"
456+
And my inbox is empty
457+
And as user "admin"
458+
And sending "post" to ocs "/apps/provisioning_api/api/v1/config/apps/libresign/identify_methods"
459+
| value | (string)[{"name":"email","enabled":true,"mandatory":true,"signatureMethods":{"emailToken":{"enabled":true}}}] |
460+
When sending "post" to ocs "/apps/libresign/api/v1/request-signature"
461+
| file | {"url":"<BASE_URL>/apps/libresign/develop/pdf"} |
462+
| users | [{"identify":{"email":"signer1@domain.test"}}] |
463+
| name | document |
464+
| status | 0 |
465+
And there should be 0 emails in my inbox
466+
When sending "post" to ocs "/apps/libresign/api/v1/request-signature"
467+
| file | {"url":"<BASE_URL>/apps/libresign/develop/pdf"} |
468+
| users | [{"identify":{"email":"signer1@domain.test"}}] |
469+
| name | document |
470+
| status | 1 |
471+
And there should be 1 email in my inbox

0 commit comments

Comments
 (0)