4
1
Fork 0

Fixed missing parse phone in CreateContact

pull/24/head
UnicodingUnicorn 2019-02-17 21:36:36 +08:00
parent 4db8c52237
commit 3ae40e9ff9
1 changed files with 3 additions and 2 deletions

View File

@ -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)