package formatter import ( "fmt" "git.db.org.ai/dborg/internal/models" "git.db.org.ai/dborg/internal/utils" ) func FormatEmailResults(response *models.EmailVerifyResponse, asJSON bool) error { if asJSON { return utils.PrintJSON(response) } PrintSection(fmt.Sprintf("📧 Email Verification: %s", Bold(response.Email))) statusColor := ColorGreen switch response.Status { case "valid": statusColor = ColorGreen case "invalid": statusColor = ColorRed case "risky", "accept_all": statusColor = ColorYellow default: statusColor = ColorGray } fmt.Printf("%s: %s", Cyan("Status"), Colorize(response.Status, statusColor)) if response.Score > 0 { scoreColor := ColorGreen if response.Score < 50 { scoreColor = ColorRed } else if response.Score < 75 { scoreColor = ColorYellow } fmt.Printf(" (Score: %s)", Colorize(fmt.Sprintf("%d/100", response.Score), scoreColor)) } fmt.Println() fmt.Println() fmt.Printf("%s\n", Bold("Validation Checks")) checks := []struct { name string passed bool }{ {"Format Valid", response.Regexp}, {"MX Records Found", response.MXRecords}, {"SMTP Server Reachable", response.SMTPServer}, {"Mailbox Verified", response.SMTPCheck}, } for _, check := range checks { status := StatusError if check.passed { status = StatusSuccess } fmt.Printf(" %s %s\n", status.String(), check.name) } if response.MXServer != "" { fmt.Printf("\n%s: %s\n", Cyan("MX Server"), response.MXServer) } fmt.Println() fmt.Printf("%s\n", Bold("Risk Indicators")) risks := []struct { name string present bool }{ {"Disposable Email", response.Disposable}, {"Webmail Service", response.Webmail}, {"Blocked Domain", response.Block}, {"Gibberish Detected", response.Gibberish}, } hasRisks := false for _, risk := range risks { if risk.present { hasRisks = true fmt.Printf(" %s %s\n", StatusWarning.String(), risk.name) } } if !hasRisks { fmt.Printf(" %s %s\n", StatusSuccess.String(), "No risk indicators found") } if response.ResponseTimeMs > 0 { fmt.Printf("\n%s: %dms\n", Dim("Response Time"), response.ResponseTimeMs) } if response.ErrorMessage != "" { fmt.Printf("\n%s: %s\n", Red("Error"), response.ErrorMessage) } if response.VerifiedAt != "" { fmt.Printf("%s: %s\n", Dim("Verified At"), response.VerifiedAt) } return nil }