Batch signature and approval notifications via debounced worker

Replace the immediate per-document approval email and the manual
"send signing notifications" action with a single debounced worker that
batches pending requests per recipient and organization.

The worker (go.gearno.de/kit/worker) polls on an interval (default 5m)
and claims one (organization, recipient) group at a time, sending one
consolidated signing email and/or one approval email per recipient/org
that lists every document awaiting their signature or approval. The
claim is a conditional UPDATE that doubles as concurrency-safe dedup, so
several workers never email the same group twice.

Each request is notified once it has been pending past the debounce
delay (default 15m), then reminded at 1x, 2x and 3x the reminder
interval (default 1 day) after the previous email, after which it stops.
New last_notified_at and notification_count columns on signatures and
approval decisions drive the debounce, the widening reminder cadence and
the four-email cap.

Email copy lists each document with its title, type and a deep link to
the employee page. Removed the inline approval-on-publish email, the
SendSigningNotifications service method/mutation/MCP tool, its IAM action,
and the related console UI and n8n operation.

Signed-off-by: Sacha Al Himdani <sacha@probo.com>
This commit is contained in:
Sacha Al Himdani
2026-06-15 09:13:31 +02:00
committed by Sacha Al Himdani
parent c9b74bac4a
commit f462b124e6
33 changed files with 1281 additions and 524 deletions

View File

@@ -1386,23 +1386,6 @@ func (r *mutationResolver) BulkRequestSignatures(ctx context.Context, input type
}, nil
}
// SendSigningNotifications is the resolver for the sendSigningNotifications field.
func (r *mutationResolver) SendSigningNotifications(ctx context.Context, input types.SendSigningNotificationsInput) (*types.SendSigningNotificationsPayload, error) {
scope, err := r.authorize(ctx, input.OrganizationID, probo.ActionDocumentSendSigningNotifications)
if err != nil {
return nil, err
}
if err := r.probo.Documents.SendSigningNotifications(ctx, scope, input.OrganizationID); err != nil {
r.logger.ErrorCtx(ctx, "cannot send signing notifications", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return &types.SendSigningNotificationsPayload{
Success: true,
}, nil
}
// CancelSignatureRequest is the resolver for the cancelSignatureRequest field.
func (r *mutationResolver) CancelSignatureRequest(ctx context.Context, input types.CancelSignatureRequestInput) (*types.CancelSignatureRequestPayload, error) {
scope, err := r.authorize(ctx, input.DocumentVersionSignatureID, probo.ActionDocumentVersionCancelSignature)

View File

@@ -567,9 +567,6 @@ extend type Mutation {
bulkRequestSignatures(
input: BulkRequestSignaturesInput!
): BulkRequestSignaturesPayload!
sendSigningNotifications(
input: SendSigningNotificationsInput!
): SendSigningNotificationsPayload!
cancelSignatureRequest(
input: CancelSignatureRequestInput!
): CancelSignatureRequestPayload!
@@ -685,10 +682,6 @@ input BulkRequestSignaturesInput {
signatoryIds: [ID!]!
}
input SendSigningNotificationsInput {
organizationId: ID!
}
input CancelSignatureRequestInput {
documentVersionSignatureId: ID!
}
@@ -782,10 +775,6 @@ type BulkRequestSignaturesPayload {
documentVersionSignatureEdges: [DocumentVersionSignatureEdge!]!
}
type SendSigningNotificationsPayload {
success: Boolean!
}
type CancelSignatureRequestPayload {
deletedDocumentVersionSignatureId: ID!
}

View File

@@ -4125,24 +4125,6 @@ func (r *Resolver) VoidDocumentVersionApprovalTool(ctx context.Context, req *mcp
}, nil
}
func (r *Resolver) SendSigningNotificationsTool(ctx context.Context, req *mcp.CallToolRequest, input *types.SendSigningNotificationsInput) (*mcp.CallToolResult, types.SendSigningNotificationsOutput, error) {
scope, err := r.Authorize(ctx, input.OrganizationID, probo.ActionDocumentSendSigningNotifications)
if err != nil {
return nil, types.SendSigningNotificationsOutput{}, err
}
svc := r.proboSvc
err = svc.Documents.SendSigningNotifications(ctx, scope, input.OrganizationID)
if err != nil {
panic(fmt.Errorf("cannot send signing notifications: %w", err))
}
return nil, types.SendSigningNotificationsOutput{
Success: true,
}, nil
}
func (r *Resolver) DeleteDocumentDraftTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteDocumentDraftInput) (*mcp.CallToolResult, types.DeleteDocumentDraftOutput, error) {
scope, err := r.Authorize(ctx, input.ID, probo.ActionDocumentDeleteDraft)
if err != nil {

View File

@@ -6570,24 +6570,6 @@ components:
approval_decision:
$ref: "#/components/schemas/DocumentVersionApprovalDecision"
SendSigningNotificationsInput:
type: object
required:
- organization_id
properties:
organization_id:
$ref: "#/components/schemas/GID"
description: Organization ID
SendSigningNotificationsOutput:
type: object
required:
- success
properties:
success:
type: boolean
description: Whether the notifications were sent successfully
WebhookEventType:
type: string
enum:
@@ -13109,14 +13091,6 @@ tools:
$ref: "#/components/schemas/VoidDocumentVersionApprovalInput"
outputSchema:
$ref: "#/components/schemas/VoidDocumentVersionApprovalOutput"
- name: sendSigningNotifications
description: Send signing notifications to all signatories with pending signature requests in the organization
hints:
readonly: false
inputSchema:
$ref: "#/components/schemas/SendSigningNotificationsInput"
outputSchema:
$ref: "#/components/schemas/SendSigningNotificationsOutput"
- name: listStatementsOfApplicability
description: List all statements of applicability for the organization
hints: