diff --git a/handlers/yo/yo.go b/handlers/yo/yo.go index f05514961..6df6a018c 100644 --- a/handlers/yo/yo.go +++ b/handlers/yo/yo.go @@ -191,6 +191,7 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) { "password": []string{password}, } + var status courier.MsgStatus encodedForm := form.Encode() sendURLs := []string{sendURL1, sendURL2, sendURL3} @@ -206,7 +207,7 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) { failed = true } // record our status and log - status := h.Backend().NewMsgStatusForID(msg.Channel(), msg.ID(), courier.MsgErrored) + status = h.Backend().NewMsgStatusForID(msg.Channel(), msg.ID(), courier.MsgErrored) status.AddLog(courier.NewChannelLogFromRR(msg.Channel(), msg.ID(), rr)) if err != nil { return status, err @@ -242,6 +243,7 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) { h.Backend().StopMsgContact(msg) return status, nil } + if failed == false { status.SetStatus(courier.MsgWired) return status, nil @@ -249,5 +251,5 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) { } - return nil, errors.Errorf("Received error from Yo! API") + return status, errors.Errorf("Received error from Yo! API") } diff --git a/handlers/yo/yo_test.go b/handlers/yo/yo_test.go index 75f01db30..b6c9035cd 100644 --- a/handlers/yo/yo_test.go +++ b/handlers/yo/yo_test.go @@ -78,6 +78,13 @@ var getSendTestCases = []ChannelSendTestCase{ URLParams: map[string]string{"sms_content": "Simple Message", "destinations": string("250788383383"), "origin": "2020"}, SendPrep: setSendURL, Stopped: true}, + {Label: "Errored wrong authorization", + Text: "Simple Message", URN: "tel:+250788383383", + Status: "E", + Error: "Received error from Yo! API", + ResponseBody: "ybs_autocreate_status=ERROR&ybs_autocreate_message=YBS+AutoCreate+Subsystem%3A+Access+denied+due+to+wrong+authorization+code", ResponseStatus: 200, + URLParams: map[string]string{"sms_content": "Simple Message", "destinations": string("250788383383"), "origin": "2020"}, + SendPrep: setSendURL}, {Label: "Unicode Send", Text: "☺", URN: "tel:+250788383383", Status: "W",