Skip to content

CP-12658 docuseal status 2#62

Merged
ryanarakawa merged 11 commits intomainfrom
CP-12658-docuseal-status-2
Mar 20, 2026
Merged

CP-12658 docuseal status 2#62
ryanarakawa merged 11 commits intomainfrom
CP-12658-docuseal-status-2

Conversation

@ryanarakawa
Copy link
Copy Markdown
Collaborator

@ryanarakawa ryanarakawa commented Mar 18, 2026

Summary

Implements the manager approval gate for single-sided Docuseal forms. When a submission is created with requires_approval: true, Docuseal suppresses the submission.completed webhook until explicitly approved via the new API endpoint. Dual-sided forms are treated as always requires_approval: false.

Changes

New API Endpoints

  • POST /api/submitters/:slug/approve - Sets approved_at on the submission.
  • POST /api/submitters/:slug/request_changes - Clears approved_at so the re-approval cycle works correctly after a submitter re-completes.

Webhook Behavior

  • requires_approval: true - form.completed fires only when the submitter finishes. submission.completed is suppressed until approval endpoint is called
  • requires_approval: false - existing behavior unchanged. submission.completed fires immediately when all submitters complete
  • Updated default webhook event set: replaced form.viewed/form.declined with submission.completed and form.changes_requested
  • Added submission_id to submission.completed payload to route to correct task

Bug Fixes

  • Fixed audit trail crash (I18n::MissingTranslationData) caused by form_update event type having no translation key
  • Disabled ExportSubmissionService direct POST to ATS (CP-12761) — submission sync now fully handled by webhooks

Cleanup

  • Removed Request Changes button from submissions/show — approval flow is API-only
  • Added backfill_account_events rake task to update existing webhook URLs to the new event set

- requires_approval gates submission.completed
- approved_at tracks when the submission was explicitly approved
- approved_at is cleared on request_changes to allow re-approval
- Sets approved_at on the submission
- Does not fire webhooks, updates itself from the 200 OK response
- Resets approved_at so re-approve is needed after submitter re-completes
- form.completed fires when submitter finishes, but submission.completed is not fired in order to wait for approval call
- submission.completed fires normally when requires_approval is false
- Replaces form.viewed/form.declined with submission.completed and form.changes_requested
- Adds backfill rake task to update existing webhook URLs to the new event set
- this was throwing an error through translation files in the audit service calls, so form.completed and submission.completed were not firing correctly.
* not sure why this wasn't auto generated previously, but it's here now
* comment out soon to be unused message
* fix failing specs
@ryanarakawa ryanarakawa marked this pull request as ready for review March 18, 2026 22:53
Copy link
Copy Markdown
Collaborator

@bernardodsanderson bernardodsanderson left a comment

Choose a reason for hiding this comment

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

Awesome work! Just one small though, totally optional.

class AddRequiresApprovalToSubmissions < ActiveRecord::Migration[7.2]
def change
add_column :submissions, :requires_approval, :boolean, default: false, null: false
add_column :submissions, :approved_at, :datetime
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[optional] Might be good to add an index to fetch the approved_at

add_index :submissions, :approved_at

* add index to submissions.approved_at
* add translations back, error was throwing when trying to find translation
@ryanarakawa ryanarakawa merged commit 5ddc761 into main Mar 20, 2026
5 checks passed
@ryanarakawa ryanarakawa deleted the CP-12658-docuseal-status-2 branch March 20, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants