Skip to content

feat: add maximum submissions limit for forms#3199

Open
LAfricain wants to merge 1 commit intonextcloud:mainfrom
LAfricain:maxsubmissions
Open

feat: add maximum submissions limit for forms#3199
LAfricain wants to merge 1 commit intonextcloud:mainfrom
LAfricain:maxsubmissions

Conversation

@LAfricain
Copy link

Add the ability to limit the number of responses a form can receive. When the limit is reached, the form is automatically closed and displays a dedicated message instead of accepting new submissions.

  • Add max_submissions column to forms_v2_forms table (migration)
  • Add maxSubmissions property to Form entity
  • Check submission limit in FormsService::canSubmit()
  • Add limit enforcement in ApiController::newSubmission()
  • Add isMaxSubmissionsReached flag in form API response
  • Add limit settings UI in SettingsSidebarTab
  • Display dedicated 'Form is full' message in Submit view
  • Add French translations for new strings

Closes #596

Copy link
Collaborator

@Chartman123 Chartman123 left a comment

Choose a reason for hiding this comment

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

@LAfricain thanks for your PR. I just had a quick look at your code and didn't test it yet in my instance. Already a few comments. :)

@Chartman123 Chartman123 added this to the 5.3 milestone Mar 3, 2026
Copy link
Collaborator

@Chartman123 Chartman123 left a comment

Choose a reason for hiding this comment

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

Some more comments :) Please have a look at the failing workflows, too.

@LAfricain
Copy link
Author

Hello @Chartman123,
I would like to know if everything is ready for a merge or if there are still some improvements to be made?
Thank you in any case for this tool!

@Chartman123
Copy link
Collaborator

@LAfricain sorry, I don't have much spare time at the moment :) Please fix the remaining workflow issues

@LAfricain
Copy link
Author

I don't have much spare time at the moment :)

It's Ok, no rush. I didn't realize I had to fix the errors myself; I still need to get used to the tool. It's done now.

@Chartman123
Copy link
Collaborator

@LAfricain yes, you have to fix them yourself (or use the npm scripts and php scripts). Environments like VSCode also can assist you with that :)

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 51.85185% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/Migration/Version050300Date20260303000000.php 0.00% 10 Missing ⚠️
lib/Controller/ApiController.php 66.66% 1 Missing ⚠️
lib/Service/FormsService.php 83.33% 1 Missing ⚠️
lib/Service/SubmissionService.php 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Chartman123
Copy link
Collaborator

@LAfricain it's getting better :) only the DCO (sign-off your commits) and OpenAPI missing... Could you then please also squash all your commits into a single one?

@Chartman123
Copy link
Collaborator

Oh, please don't merge the main branch into this PR, always use git rebase -i main. There you can also squash the commits into a single one :)

@LAfricain LAfricain force-pushed the maxsubmissions branch 2 times, most recently from d1c6101 to 05bfd72 Compare March 13, 2026 07:33
Copy link
Collaborator

@Chartman123 Chartman123 left a comment

Choose a reason for hiding this comment

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

a few more comments that came up during test

Comment on lines +491 to +496
// Check if max submissions limit is reached
$maxSubmissions = $form->getMaxSubmissions();
if ($maxSubmissions !== null && $this->submissionMapper->countSubmissions($form->getId()) >= $maxSubmissions) {
return false;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

This check fails once the submission reaches the limit as this part of the code is called after inserting the submission.

@susnux do you think a single check for maxSubmissions is enough in ApiController or do we need the double check here as well? If so, we need to change the condition from >= to >

Add the ability to limit the number of responses a form can receive.
When the limit is reached, the form is automatically closed and displays
a dedicated message instead of accepting new submissions.

- Add max_submissions column to forms_v2_forms table (migration)
- Add maxSubmissions property to Form entity
- Check submission limit in FormsService::canSubmit()
- Add limit enforcement in ApiController::newSubmission()
- Add isMaxSubmissionsReached flag in form API response
- Update FormsForm psalm type in ResponseDefinitions
- Add limit settings UI in SettingsSidebarTab
- Display dedicated 'Form is full' message in Submit view
- Update openapi.json
- Update unit and integration tests

Closes nextcloud#596

Signed-off-by: lafricain79 <lafricain79@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limit Number of Answers

2 participants