From 3ae40e9ff9929823a7937773004cfd08eba07a00 Mon Sep 17 00:00:00 2001 From: UnicodingUnicorn <7555ic@gmail.com> Date: Sun, 17 Feb 2019 21:36:36 +0800 Subject: [PATCH] Fixed missing parse phone in CreateContact --- handlers.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/handlers.go b/handlers.go index 321cb58..a796e5f 100644 --- a/handlers.go +++ b/handlers.go @@ -448,7 +448,8 @@ func (h *Handler) CreateContact(w http.ResponseWriter, r *http.Request, p httpro } // Validate - if len(contact.PhoneNumber) < 1 { + phone, err := ParsePhone(contact.PhoneNumber) + if err != nil || len(contact.PhoneNumber) < 1 { http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) return } @@ -464,7 +465,7 @@ func (h *Handler) CreateContact(w http.ResponseWriter, r *http.Request, p httpro ON CONFLICT(phone_number) DO UPDATE SET phone_number=EXCLUDED.phone_number RETURNING id - `, id, contact.PhoneNumber).Scan(&contactId) + `, id, phone).Scan(&contactId) if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) log.Print(err)