diff --git a/lib/Service/ApprovalService.php b/lib/Service/ApprovalService.php index 5f0aebf6..ba7f8b13 100644 --- a/lib/Service/ApprovalService.php +++ b/lib/Service/ApprovalService.php @@ -446,7 +446,16 @@ public function reject(int $fileId, ?string $userId, string $message = '', strin * @throws \OCP\Files\NotPermittedException * @throws \OC\User\NoUserException */ - public function request(int $fileId, int $ruleId, ?string $userId, bool $createShares): array { + public function request(int $fileId, int $ruleId, ?string $userId, bool $createShares) { + + $state = $this->getApprovalState($fileId, $userId); + + if ($state['state'] === \OCA\Approval\AppInfo\Application::STATE_APPROVED) { + return [ + 'error' => 'File already approved. Cannot request approval again.' + ]; + } + if (!$this->utilsService->userHasAccessTo($fileId, $userId)) { return ['error' => $this->l10n->t('You do not have access to this file')]; } diff --git a/src/components/Info.vue b/src/components/Info.vue index 9655879c..cf46718d 100644 --- a/src/components/Info.vue +++ b/src/components/Info.vue @@ -188,7 +188,7 @@ export default { return this.userId !== getCurrentUser().uid }, canRequestApproval() { - return this.userRules.length > 0 + return this.userRules.length > 0 && this.state !== states.APPROVED }, ruleText() { if (