fix(integration): webhook v2 events, storage migrate, test theatre
- F1: DOCUMENT_DECLINED handler (v2 Decline vs Reject) — routes to same handler as DOCUMENT_REJECTED until product refines downstream UX - Add RECIPIENT_VIEWED / RECIPIENT_SIGNED v2-alias cases with telemetry logging so we see when v2 deployments emit them - D1: populate TABLES_WITH_STORAGE_KEYS (files, berth_pdf_versions, brochure_versions, gdpr_exports) — was an empty list, migrated 0 files - MinIO putObject/getObject/statObject/removeObject socket timeout wrapper to prevent worker hangs on TCP blackhole (30s deadline) - E1: convert test.skip on smoke-setup infra failure to throw new Error so green-skipped silence becomes a real test failure (Playwright doesn't expose vitest's expect.fail) - Regression tests: folderId='' → null transform, applyEntityRestoredSuffix no-op (never-archived), syncEntityFolderName collision loop past (2) Note: matching .env.example documentation (D2 — bare DOCUMENSO_API_URL, DOCUMENSO_API_VERSION, MINIO_AUTO_CREATE_BUCKET, DOCUMENSO_TEMPLATE_ID_EOI, recipient role id vars) prepared but not committed — pre-commit hook blocks .env*. Apply manually via the separate .env workflow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -145,9 +145,19 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
try {
|
||||
switch (event) {
|
||||
case 'DOCUMENT_SIGNED':
|
||||
case 'DOCUMENT_RECIPIENT_COMPLETED': {
|
||||
case 'DOCUMENT_RECIPIENT_COMPLETED':
|
||||
case 'RECIPIENT_SIGNED': {
|
||||
// v1.13 fires DOCUMENT_SIGNED per recipient sign;
|
||||
// 2.x fires DOCUMENT_RECIPIENT_COMPLETED for the same semantics.
|
||||
// Some 2.x deployments emit RECIPIENT_SIGNED as a v2-flavoured alias —
|
||||
// log when we see it (telemetry) and route to the same handler so v2
|
||||
// deployments don't silently drop per-recipient signs.
|
||||
if (event === 'RECIPIENT_SIGNED') {
|
||||
logger.info(
|
||||
{ event, documensoId },
|
||||
'Documenso v2 RECIPIENT_SIGNED received — routing to recipient-signed handler',
|
||||
);
|
||||
}
|
||||
const signedRecipients = recipients.filter(
|
||||
(r) => r.signingStatus === 'SIGNED' || Boolean(r.signedAt),
|
||||
);
|
||||
@@ -162,13 +172,23 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'DOCUMENT_OPENED': {
|
||||
case 'DOCUMENT_OPENED':
|
||||
case 'RECIPIENT_VIEWED': {
|
||||
// Documenso v1 sends `readStatus: 'OPENED'`; v2 has used both
|
||||
// upper and lower case across releases and may omit the field
|
||||
// entirely (the event itself signals the open). Treat the event
|
||||
// as the signal: dispatch a per-recipient open for every
|
||||
// recipient on the document so v2 deployments stop silently
|
||||
// dropping opens.
|
||||
//
|
||||
// RECIPIENT_VIEWED is the v2-flavoured alias for the same semantics
|
||||
// — log when we see it (telemetry) and route to the same handler.
|
||||
if (event === 'RECIPIENT_VIEWED') {
|
||||
logger.info(
|
||||
{ event, documensoId },
|
||||
'Documenso v2 RECIPIENT_VIEWED received — routing to document-opened handler',
|
||||
);
|
||||
}
|
||||
const openedRecipients = recipients.filter(
|
||||
(r) => !r.readStatus || String(r.readStatus).toUpperCase() === 'OPENED',
|
||||
);
|
||||
@@ -187,8 +207,17 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
await handleDocumentCompleted({ documentId: documensoId, ...portScope });
|
||||
break;
|
||||
|
||||
case 'DOCUMENT_REJECTED': {
|
||||
const rejecting = recipients.find((r) => r.signingStatus === 'REJECTED');
|
||||
case 'DOCUMENT_REJECTED':
|
||||
case 'DOCUMENT_DECLINED': {
|
||||
// Documenso v2 distinguishes Decline (recipient refuses to sign) from
|
||||
// Reject (admin cancels). Both currently map to the same "rejected"
|
||||
// terminal state in our domain — `handleDocumentRejected` records who
|
||||
// refused and freezes the workflow. Product may later refine
|
||||
// downstream UX (different audit tags / notifications), but the
|
||||
// storage shape is identical for now so they share a handler.
|
||||
const rejecting = recipients.find(
|
||||
(r) => r.signingStatus === 'REJECTED' || r.signingStatus === 'DECLINED',
|
||||
);
|
||||
await handleDocumentRejected({
|
||||
documentId: documensoId,
|
||||
recipientEmail: rejecting?.email,
|
||||
|
||||
Reference in New Issue
Block a user