From 3fdc02d1468f5a17481fc5345ad946780d2b9e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Dvo=C5=99=C3=A1k?= <150935816+Dvorinka@users.noreply.github.com> Date: Fri, 23 May 2025 10:33:23 +0200 Subject: [PATCH] Add files via upload --- kontakt/contact-scrape.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/kontakt/contact-scrape.go b/kontakt/contact-scrape.go index 94511cb..0767b06 100644 --- a/kontakt/contact-scrape.go +++ b/kontakt/contact-scrape.go @@ -21,6 +21,7 @@ type Contact struct { Phone string `json:"phone,omitempty"` ServicePhone string `json:"service_phone,omitempty"` Internal bool `json:"internal"` + PhoneFlap string `json:"phone_flap,omitempty"` } type ContactData struct { @@ -222,7 +223,7 @@ func parseTable(f *excelize.File, sheetName, startCol, endCol string) []Contact positionCol = 1 phoneCol = 2 servicePhoneCol = 3 - mobileKlapkaCol = 4 + flapCol = 4 ) for i := startRow; i < endRow; i++ { @@ -243,11 +244,12 @@ func parseTable(f *excelize.File, sheetName, startCol, endCol string) []Contact Position: safeGet(row, positionCol, ""), Phone: formatPhoneNumber(safeGet(row, phoneCol, "")), ServicePhone: formatPhoneNumber(safeGet(row, servicePhoneCol, "")), + PhoneFlap: formatPhoneFlap(safeGet(row, flapCol, "")), } // Check for mobile klapka if exists - if len(row) > mobileKlapkaCol && row[mobileKlapkaCol] != "" { - contact.ServicePhone = formatPhoneNumber(row[mobileKlapkaCol]) + if len(row) > 4 && row[4] != "" { + contact.ServicePhone = formatPhoneNumber(row[4]) } contacts = append(contacts, contact) @@ -288,6 +290,17 @@ func formatPhoneNumber(phone string) string { return phone } +func formatPhoneFlap(flap string) string { + flap = strings.TrimSpace(flap) + if flap == "" { + return "" + } + if !strings.HasPrefix(flap, "*") { + return "*" + flap + } + return flap +} + func processContacts(contacts []Contact) *ContactData { var data ContactData data.Contacts = []Contact{}