From 79ceec3b320ec45fb91ff4291dbc04069184a57b Mon Sep 17 00:00:00 2001 From: Matthew Meszaros Date: Thu, 27 Aug 2026 03:44:27 -0700 Subject: [PATCH] feat: add the ContactImportTargetCustom column target so a client can say {target:"custom", custom_key:"Company Mobile"} instead of packing the name into a "custom:" string, and add MaxContactImportReportedErrors with an ErrorsTruncated result flag so a 50k-row file of bad addresses reports the first thousand failures with an honest total rather than echoing the whole upload back as JSON --- internal/models/contact_import.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/models/contact_import.go b/internal/models/contact_import.go index b0f232f8..f73b1d14 100644 --- a/internal/models/contact_import.go +++ b/internal/models/contact_import.go @@ -42,6 +42,10 @@ const ( ContactImportTargetPhone ContactImportColumnTarget = "phone" ContactImportTargetSubscribed ContactImportColumnTarget = "subscribed" ContactImportTargetCategories ContactImportColumnTarget = "categories" + // ContactImportTargetCustom routes the column into Contact.CustomFields + // under ContactImportColumnMapping.CustomKey. "custom:" is accepted + // as an equivalent legacy spelling. + ContactImportTargetCustom ContactImportColumnTarget = "custom" ) // ContactImportColumnMapping says "the column at this index maps to @@ -108,6 +112,11 @@ type ContactImportRowError struct { Reason string `json:"reason"` } +// MaxContactImportReportedErrors caps how many per-row failures travel back +// in the response. Failed still counts every one; without the cap a 50k-row +// file of bad addresses would echo the whole file back as JSON. +const MaxContactImportReportedErrors = 1000 + type ContactImportResult struct { Total int `json:"total"` Imported int `json:"imported"` @@ -118,4 +127,7 @@ type ContactImportResult struct { EndedAt time.Time `json:"ended_at"` Errors []ContactImportRowError `json:"errors,omitempty"` + // ErrorsTruncated is true when Failed exceeds the reported-error cap, so + // the UI can say "showing the first N of M". + ErrorsTruncated bool `json:"errors_truncated,omitempty"` }