rdev/internal/port/notify_provisioner.go
jordan fa0d030def
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
feat: improve notify domain verification reliability and add status endpoints
- Add verifyWithRetry to provisioner: 60s initial DNS propagation delay,
  5 retries with 30s backoff before marking verification as failed
- Add GetNotifyDomainStatus: polls Resend API for domain verification status,
  returns "not_configured" when Resend not set up
- Add VerifyProjectNotify: synchronous re-verification for handler use
- Add getDomainStatus to resendAPI interface + resendClient implementation
- Add NotifyDomainStatus domain struct (host, resend_domain_id, status)
- Guard NOTIFY_RESEND_DOMAIN_ID storage against empty string writes
- New handler: GET /projects/{id}/notify/status (returns verification state)
- New handler: POST /projects/{id}/notify/verify (triggers re-verification)
- Add verify-notify-domain cookbook step to persona-community,
  slackpath-1, and slackpath-4 trees (polls status for up to 6 min)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 16:25:55 -07:00

34 lines
1.5 KiB
Go

package port
import (
"context"
"github.com/orchard9/rdev/internal/domain"
)
// NotifyProvisioner manages per-project email delivery on the notify service.
// Each project gets its own isolated sending host (mail.{slug}.threesix.ai),
// Resend domain with DKIM/SPF, and a dedicated notify account with send key.
type NotifyProvisioner interface {
// CreateProjectNotify provisions a notify host, Resend domain, DNS records,
// and account with send key for the project.
CreateProjectNotify(ctx context.Context, projectID, slug string) (*domain.NotifyCredentials, error)
// DeleteProjectNotify removes all notify resources for a project:
// the notify account, the per-project host, the Resend domain, and DNS records.
DeleteProjectNotify(ctx context.Context, projectID, slug, resendDomainID string) error
// GetProjectNotify returns notify credentials for a project, or nil if not provisioned.
GetProjectNotify(ctx context.Context, projectID string) (*domain.NotifyCredentials, error)
// TestConnection verifies the admin API key and notify service are reachable.
TestConnection(ctx context.Context) error
// VerifyProjectNotify triggers Resend domain verification for the given resend domain ID.
// Should be called after DNS records have had time to propagate.
VerifyProjectNotify(ctx context.Context, projectID, resendDomainID string) error
// GetNotifyDomainStatus returns the Resend verification status for the project's email domain.
GetNotifyDomainStatus(ctx context.Context, host, resendDomainID string) (*domain.NotifyDomainStatus, error)
}