Skip to content

Fix: Prevent re-requesting approval for already approved files - #399

Merged
lukasdotcom merged 2 commits into
nextcloud:mainfrom
Amitdwivedi22:fix/prevent-duplicate-approval
Apr 6, 2026
Merged

Fix: Prevent re-requesting approval for already approved files#399
lukasdotcom merged 2 commits into
nextcloud:mainfrom
Amitdwivedi22:fix/prevent-duplicate-approval

Conversation

@Amitdwivedi22

@Amitdwivedi22 Amitdwivedi22 commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Fix: Prevent re-requesting approval for already approved files

  • Added backend validation in ApprovalService to block approval requests if file is already approved
  • Improved frontend logic to hide request button after approval

Closes #398

@lukasdotcom lukasdotcom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Amitdwivedi22,

Thanks for the contribution. Could you sign your commits? There are instructions at https://github.com/nextcloud/approval/pull/399/checks?check_run_id=67481178296

Comment thread lib/Service/ApprovalService.php Outdated
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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is done before ensuring that the user has access to the file which could leak information.

Comment thread lib/Service/ApprovalService.php Outdated

$state = $this->getApprovalState($fileId, $userId);

if ($state['state'] === \OCA\Approval\AppInfo\Application::STATE_APPROVED) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($state['state'] === \OCA\Approval\AppInfo\Application::STATE_APPROVED) {
if ($state['state'] === Application::STATE_APPROVED) {

Comment thread src/components/Info.vue Outdated
},
canRequestApproval() {
return this.userRules.length > 0
return this.userRules.length > 0 && this.state !== states.APPROVED

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessary as it only matters that you can't re-request approval for the same workflow. Some users may have two approval flows they want on the same file.

@lukasdotcom

Copy link
Copy Markdown
Member

For fixing the php-cs workflow you can run composer cs:fix

@lukasdotcom

Copy link
Copy Markdown
Member

Hi @Amitdwivedi22,

Are you still interested in working on this?

@Amitdwivedi22

Amitdwivedi22 commented Mar 31, 2026 via email

Copy link
Copy Markdown
Contributor Author

Amitdwivedi22 and others added 2 commits April 6, 2026 10:51
Signed-off-by: Lukas Schaefer <lukas@lschaefer.xyz>
Signed-off-by: Lukas Schaefer <lukas@lschaefer.xyz>
@lukasdotcom
lukasdotcom force-pushed the fix/prevent-duplicate-approval branch from 0a0368e to d4255a6 Compare April 6, 2026 14:53
@lukasdotcom
lukasdotcom merged commit 6492935 into nextcloud:main Apr 6, 2026
42 checks passed
@lukasdotcom lukasdotcom mentioned this pull request Apr 14, 2026
@github-actions

Copy link
Copy Markdown

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API allows rerequesting approval of approved files

2 participants