mirror of
https://github.com/warmbly/warmbly.git
synced 2026-09-05 08:01:23 +00:00
* feat: index advisor findings by subject and parent entity so a list page fetches its whole surface once and every row resolves its own advice from the shared cache instead of firing a request per row * feat: rebuild the advisor fix drawer as a three-screen resolution flow (why it fired with the measured evidence, the exact before and after, then an animated outcome with undo) with a progress rail and direction-aware transitions, and deep-link manual fixes to the screen where they are made * feat: add AdvisorRowFlag, the inline per-row advisor indicator that renders on the mailbox or campaign the problem is about and opens that row's findings in an anchored panel instead of making the reader join a card list against a table * feat: add AdvisorSummaryBar, a one-line collapsible page summary that replaces the stack of advisor cards above a list, counts the distinct rows implicated rather than the findings, and forces itself open only for critical or workspace-level advice no row flag can carry * feat: put advisor advice on the mailbox row it is about in the accounts list, replace the card stack above the table with the collapsible summary bar, and support ?mailbox=<id> so a finding can deep-link straight to the mailbox detail instead of the top of the list * feat: flag advisor findings on the campaign row in the campaigns list, including step-level copy problems which index onto their parent campaign since a step has no row of its own, and add the collapsible summary bar above the list * feat: move the deliverability and contacts pages onto the collapsible advisor summary bar so their findings stop pushing the numbers they describe below the fold * feat: add an ordered Steps field to advisor findings, persisted as text[] and always refreshed from the current build, and write real how-to steps for the deliverability checks that have no one-click fix (bounce rate, spam placement, tracking domain, and per-record SPF/DKIM/DMARC instructions) * feat: write ordered how-to steps for the manual advisor findings where the remedy alone leaves someone stuck (broken template syntax, missing first-name fallback, unsubscribed contacts still enrolled, a campaign with no resolvable sender, and a mailbox that lost warmup pool standing) and correct the personalization detail that named a merge syntax this product does not use * feat: show a mailbox's advisor findings at the top of its detail drawer, which is where both the row flag and the ?mailbox deep link now land * feat: open the resolution flow from findings that have no one-click fix too, since the ordered how-to lives there and a card with no Fix button previously left the steps unreachable * docs: document the per-row advisor flags, the collapsible page summary, the three-screen resolution flow, and the ordered manual steps for findings with no one-click fix * feat: align the advisor summary bar to the px-5 page gutter used by SectionBar and the list rows on all four surfaces, instead of sitting flush against the edge while the table it describes is indented * fix: stop the resolution drawer collapsing to zero height between screens by switching the step transition to popLayout with a layout-animated container, so the dialog resizes into the next screen instead of snapping shut and reopening * feat: wire the advisor repository, narrator, service, tool registration, and background runner into the backend boot path so findings evaluate on a schedule and the assistant can read them * docs: register the advisor guide in the sidebar, add its endpoint scope table to the API reference, and document the sandbox advisor showcase * fix: darken the advisor nav badge to solid orange-600 on white instead of a pale amber-100 chip that read as a disabled control beside the sidebar's saturated indicators, and drop the critical badge to rose-600 so the two stay in the same weight class * fix: use orange-500 for the advisor nav badge, matching the high-severity dot on the row it points at, rather than the darker orange-600 * feat: add an Auto safety class to advisor actions and mark the seven fixes autopilot may apply unattended (the cap cuts, the send-gap widen, the campaign limit matches, and the unsubscribe header), with a test pinning the boundary so nothing that halts sending or generates new outbound mail can drift into it * feat: add advisor autopilot, which applies the auto-safe fixes unattended as the member who switched it on, resolving their live permissions each run so it fails closed when they leave the org, bounded to 10 changes per evaluation and audited per fix like any hand-made change * feat: add the advisor agent fix, a bounded per-finding agent run that resolves the problems a settings change cannot (broken template syntax, bulk-reading copy, shared-inbox lists) as the calling member inside a tool allowlist scoped to the finding's category, metered per iteration and marked applied only when it actually called a write tool * feat: surface autopilot and the agent fix in the dashboard, adding the workspace toggle that names exactly which changes it may make, an Auto chip on the findings it is allowed to take, and an agent-fix path in the resolution drawer that reports the tools it actually called rather than only its own account of them * docs: document the agent fix and autopilot, naming the exact set of changes autopilot may make, that it acts as the member who enabled it and stops when they leave, and why the agent-fix endpoint is JWT only * fix: gate the agent fix per detector instead of per category, so a missing DMARC record no longer offers a Fix-with-agent button it can never satisfy and then reports failure; findings whose fix lives in DNS or a provider console now show their manual steps, and the client is told which is which via agent_fixable * feat: soften the advisor surfaces to translucent washes, replacing the filled nav badge with a tinted pill that carries its colour in the text, frosting the row panel and the resolution drawer, and turning the severity chips and cards into layers the page shows through * docs: correct the agent-fix scope to name the findings it cannot resolve, and why a DNS record shows steps instead of a button * feat: ship the actual DNS records for the findings that live outside the platform, with the provider's SPF include resolved, the DMARC record scoped to the sending domain and starting at p=none, the DKIM host plus the console that generates its value, and a tracking CNAME pointing at this install's own tracking host * feat: render advisor snippets as labelled copy-button rows so a DNS record is one click per field rather than a text-selection exercise, with no copy affordance on a value the server could not supply * docs: document the pasteable DNS records and the guarantee that every check offers a fix, an agent, or ordered steps * fix: bump golang.org/x/text to 0.39.0 to clear CVE-2026-56852, a HIGH-severity infinite loop in norm.Iter that Trivy started failing the security scan on
262 lines
10 KiB
Go
262 lines
10 KiB
Go
package handler
|
|
|
|
import (
|
|
"github.com/warmbly/warmbly/internal/app/admin"
|
|
"github.com/warmbly/warmbly/internal/app/adminoutreach"
|
|
"github.com/warmbly/warmbly/internal/app/advanced"
|
|
"github.com/warmbly/warmbly/internal/app/advisor"
|
|
"github.com/warmbly/warmbly/internal/app/aiagent"
|
|
"github.com/warmbly/warmbly/internal/app/aitools"
|
|
"github.com/warmbly/warmbly/internal/app/analytics"
|
|
"github.com/warmbly/warmbly/internal/app/apikey"
|
|
"github.com/warmbly/warmbly/internal/app/audit"
|
|
"github.com/warmbly/warmbly/internal/app/auth"
|
|
"github.com/warmbly/warmbly/internal/app/campaign"
|
|
"github.com/warmbly/warmbly/internal/app/compose"
|
|
"github.com/warmbly/warmbly/internal/app/contact"
|
|
"github.com/warmbly/warmbly/internal/app/credits"
|
|
"github.com/warmbly/warmbly/internal/app/crm"
|
|
"github.com/warmbly/warmbly/internal/app/dangerzone"
|
|
"github.com/warmbly/warmbly/internal/app/discount"
|
|
"github.com/warmbly/warmbly/internal/app/email"
|
|
"github.com/warmbly/warmbly/internal/app/emailsend"
|
|
emailverifyapp "github.com/warmbly/warmbly/internal/app/emailverify"
|
|
"github.com/warmbly/warmbly/internal/app/feature"
|
|
"github.com/warmbly/warmbly/internal/app/group"
|
|
"github.com/warmbly/warmbly/internal/app/integration"
|
|
"github.com/warmbly/warmbly/internal/app/leadsync"
|
|
"github.com/warmbly/warmbly/internal/app/mcp"
|
|
"github.com/warmbly/warmbly/internal/app/notification"
|
|
"github.com/warmbly/warmbly/internal/app/oauth"
|
|
"github.com/warmbly/warmbly/internal/app/organization"
|
|
"github.com/warmbly/warmbly/internal/app/passkey"
|
|
"github.com/warmbly/warmbly/internal/app/placement"
|
|
"github.com/warmbly/warmbly/internal/app/ratelimit"
|
|
"github.com/warmbly/warmbly/internal/app/referral"
|
|
"github.com/warmbly/warmbly/internal/app/releases"
|
|
"github.com/warmbly/warmbly/internal/app/research"
|
|
"github.com/warmbly/warmbly/internal/app/sequence"
|
|
"github.com/warmbly/warmbly/internal/app/skills"
|
|
"github.com/warmbly/warmbly/internal/app/socket"
|
|
"github.com/warmbly/warmbly/internal/app/stripe"
|
|
"github.com/warmbly/warmbly/internal/app/subscription"
|
|
"github.com/warmbly/warmbly/internal/app/sysstatus"
|
|
"github.com/warmbly/warmbly/internal/app/team"
|
|
"github.com/warmbly/warmbly/internal/app/template"
|
|
"github.com/warmbly/warmbly/internal/app/token"
|
|
"github.com/warmbly/warmbly/internal/app/trial"
|
|
"github.com/warmbly/warmbly/internal/app/twofa"
|
|
"github.com/warmbly/warmbly/internal/app/tz"
|
|
"github.com/warmbly/warmbly/internal/app/unibox"
|
|
"github.com/warmbly/warmbly/internal/app/user"
|
|
"github.com/warmbly/warmbly/internal/app/warmup"
|
|
"github.com/warmbly/warmbly/internal/app/warmupcontent"
|
|
"github.com/warmbly/warmbly/internal/app/webhook"
|
|
"github.com/warmbly/warmbly/internal/app/worker"
|
|
"github.com/warmbly/warmbly/internal/app/worker_orchestrator"
|
|
"github.com/warmbly/warmbly/internal/pkg/generation"
|
|
|
|
"github.com/warmbly/warmbly/internal/infrastructure/encryptedkeys"
|
|
"github.com/warmbly/warmbly/internal/infrastructure/pubsub"
|
|
"github.com/warmbly/warmbly/internal/infrastructure/storage"
|
|
"github.com/warmbly/warmbly/internal/models"
|
|
"github.com/warmbly/warmbly/internal/notify"
|
|
"github.com/warmbly/warmbly/internal/repository"
|
|
"github.com/warmbly/warmbly/internal/tasks"
|
|
)
|
|
|
|
type Handler struct {
|
|
AuthService auth.AuthService
|
|
TokenService token.TokenService
|
|
PasskeyService passkey.Service
|
|
|
|
// Native-app social sign-in discovery (GET /auth/providers).
|
|
ExternalAuthProviders models.ExternalAuthProviders
|
|
UserService user.UserService
|
|
EmailService email.EmailService
|
|
CampaignService campaign.CampaignService
|
|
ContactService contact.ContactService
|
|
SequenceService sequence.SequenceService
|
|
UniboxService unibox.UniboxService
|
|
|
|
FolderService group.GroupService
|
|
TagService group.GroupService
|
|
CategoryService group.GroupService
|
|
|
|
TzService tz.TzService
|
|
SocketService socket.SocketService
|
|
TasksService tasks.TasksService
|
|
NotificationService notification.Service
|
|
TwoFAService twofa.Service
|
|
|
|
// New services
|
|
APIKeyService apikey.APIKeyService
|
|
AnalyticsService analytics.AnalyticsService
|
|
AuditService audit.AuditService
|
|
RateLimitService ratelimit.RateLimitService
|
|
|
|
// Subscription & billing
|
|
SubscriptionService subscription.SubscriptionService
|
|
StripeService stripe.StripeService
|
|
DiscountService discount.DiscountService
|
|
ReferralService referral.Service
|
|
|
|
// Trial & feature gates
|
|
TrialService trial.TrialService
|
|
FeatureGateService feature.FeatureGateService
|
|
WorkerAssignmentService worker.WorkerAssignmentService
|
|
|
|
// Organization & IAM
|
|
OrganizationService organization.OrganizationService
|
|
|
|
// CRM
|
|
CRMService crm.CRMService
|
|
|
|
// Teams
|
|
TeamService team.TeamService
|
|
|
|
// Email send & templates
|
|
TemplateService template.TemplateService
|
|
EmailSendService emailsend.EmailSendService
|
|
|
|
// Compose mailbox picker: scores the org's mailboxes for a recipient
|
|
// (affinity, budget, auth health) and backs auto selection.
|
|
ComposeService compose.Service
|
|
|
|
// Admin
|
|
AdminService admin.AdminService
|
|
AdminOutreachService adminoutreach.Service
|
|
|
|
// Worker orchestration (SSH-driven lifecycle for admin-managed workers)
|
|
WorkerOrchestrator *worker_orchestrator.Orchestrator
|
|
WorkerRepo repository.WorkerRepository
|
|
CredentialsRepo repository.CredentialsRepository
|
|
ReleasesService *releases.Service
|
|
|
|
// Notifications
|
|
EmailNotificationService notify.EmailNotificationService
|
|
|
|
// Advanced outreach controls
|
|
AdvancedService advanced.Service
|
|
|
|
// Pre-send email verification (control-plane SMTP RCPT probe / pluggable
|
|
// paid backend). Drops hard-bouncing addresses before a worker sends.
|
|
EmailVerifyService emailverifyapp.Service
|
|
|
|
// Warmup health
|
|
WarmupService warmup.Service
|
|
|
|
// Warmup routing rules — customer-defined preferences for premium-pool
|
|
// partner selection (e.g. Gmail recipients from Google Workspace senders).
|
|
WarmupRoutingRepo repository.WarmupRoutingRepository
|
|
|
|
// Warmup content bank + offline AI generator (admin control/visibility).
|
|
WarmupContentRepo repository.WarmupContentRepository
|
|
WarmupContentService warmupcontent.Service
|
|
|
|
// AI writing assistant + credit ledger.
|
|
CreditService credits.CreditService
|
|
WritingGenerator generation.WritingGenerator
|
|
|
|
// AI provider layer (RunAgent tool-loop backend) + pluggable web search,
|
|
// shared by the dashboard agent, research, automation AI nodes, and the
|
|
// inbox agent. Nil when no LLM provider is configured.
|
|
AIProvider generation.Provider
|
|
AISearch generation.SearchClient
|
|
|
|
// AITools is the shared tool registry the dashboard agent and MCP server
|
|
// run on. Handlers bound to the invoking user's permissions.
|
|
AITools *aitools.Registry
|
|
|
|
// AIAgentService orchestrates the dashboard agent (sessions, SSE runs,
|
|
// approvals, per-iteration credits). Nil when no LLM provider is configured.
|
|
AIAgentService aiagent.Service
|
|
|
|
// ResearchService runs the AI contact-research agent (sync + batch).
|
|
ResearchService research.Service
|
|
|
|
// SkillsService manages org AI skills (playbooks) and injects them into AI
|
|
// prompts.
|
|
SkillsService skills.Service
|
|
|
|
// MCPService manages org-connected MCP servers (external tools).
|
|
MCPService mcp.Service
|
|
|
|
// AIDraftRepo stores inbox-agent reply drafts awaiting human review (M10).
|
|
// The draft is created in the consumer; these list/approve/discard handlers
|
|
// read + resolve it. Nil disables the review endpoints.
|
|
AIDraftRepo repository.AIDraftRepository
|
|
|
|
// Seed inbox-placement testing.
|
|
PlacementRepo repository.PlacementRepository
|
|
PlacementService placement.Service
|
|
|
|
// Advisor: continuously-evaluated recommendations about deliverability,
|
|
// mailbox config, warmup, campaign performance, copy, and list hygiene.
|
|
// The repository is held alongside the service so a read can cheaply check
|
|
// how stale the findings are before deciding to re-evaluate inline.
|
|
AdvisorService advisor.Service
|
|
AdvisorRepository repository.AdvisorRepository
|
|
|
|
// Customer-facing webhooks (subscribe → HMAC-signed delivery).
|
|
WebhookService webhook.Service
|
|
|
|
// Third-party integrations (Calendly, Cal.com, DMARC, Postmaster,
|
|
// SNDS, Cloudflare, GoDaddy, Namecheap, Google Sheets).
|
|
IntegrationService integration.Service
|
|
ContactRepo repository.ContactRepository
|
|
|
|
// OAuth 2.1 authorization server (third-party app registration + the
|
|
// authorization-code-with-PKCE flow + bearer-token validation).
|
|
OAuthService *oauth.Service
|
|
|
|
// Realtime publisher for handler paths that emit live dashboard events
|
|
// directly (inbound meeting webhooks have no service layer of their own).
|
|
// nil-safe: realtime is a nicety, not a requirement.
|
|
StreamingPublisher *pubsub.StreamingPublisher
|
|
|
|
// On-demand Google Sheets -> leads sync. Reuses the google_sheets OAuth
|
|
// connection's token to read sheets and the contact import path to upsert.
|
|
LeadSyncService leadsync.Service
|
|
|
|
// Public websocket URL used by frontend clients
|
|
WebsocketURI string
|
|
|
|
// Object storage for user-uploaded artifacts (avatars, etc.).
|
|
Storage storage.Store
|
|
|
|
// Encrypted-DEK store. Served to workers over HTTPS at
|
|
// /api/v1/internal/dek/:userID so workers don't need direct Postgres
|
|
// access. Backend processes use Postgres directly; workers use the
|
|
// HTTP-proxy implementation.
|
|
EncryptedKeys encryptedkeys.Store
|
|
|
|
// Worker messageId -> internal email map, served to workers over HTTPS at
|
|
// /api/v1/internal/email-message-map for the same no-direct-Postgres reason
|
|
// as EncryptedKeys. Backed by Postgres in the backend.
|
|
EmailMessageMap repository.EmailMessageMapRepository
|
|
|
|
// Click-link store, served to the tracking service over HTTPS at
|
|
// /api/v1/internal/tracked-links/:id (same no-direct-Postgres rule).
|
|
TrackedLinks repository.TrackedLinkRepository
|
|
|
|
// Direct repositories used by handlers that don't yet have a
|
|
// service layer (avatars, etc.). Keep narrow and add a service
|
|
// only when business logic accumulates.
|
|
UserRepo repository.UserRepository
|
|
OrgRepo repository.OrganizationRepository
|
|
AttachmentRepo repository.AttachmentRepository
|
|
StorageBackendRepo repository.StorageBackendRepository
|
|
CloudCredentialRepo repository.CloudCredentialRepository
|
|
ProvisioningTemplateRepo repository.ProvisioningTemplateRepository
|
|
ProvisioningJobRepo repository.ProvisioningJobRepository
|
|
ProvisioningPolicyRepo repository.ProvisioningPolicyRepository
|
|
|
|
// Danger zone (delayed deletions for orgs & user accounts)
|
|
DangerZoneService dangerzone.Service
|
|
|
|
// Infrastructure liveness probes for the admin System Status page.
|
|
// Wired in cmd/backend/main.go where the concrete clients live.
|
|
SystemChecker *sysstatus.Checker
|
|
}
|