Skip to content

Commit

Permalink
Merge branch 'infobip-updates' of github.com:nyaruka/courier into zen…
Browse files Browse the repository at this point in the history
…via-handlers
  • Loading branch information
norkans7 committed Nov 17, 2017
2 parents c4ff1d4 + a51809d commit cca9b45
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions handlers/infobip/infobip.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ func (h *handler) Initialize(s courier.Server) error {

// StatusMessage is our HTTP handler function for status updates
func (h *handler) StatusMessage(channel courier.Channel, w http.ResponseWriter, r *http.Request) ([]courier.MsgStatus, error) {
ibStatusEnvelop := &ibStatusEnvelop{}
err := handlers.DecodeAndValidateJSON(ibStatusEnvelop, r)
ibStatusEnvelope := &ibStatusEnvelope{}
err := handlers.DecodeAndValidateJSON(ibStatusEnvelope, r)
if err != nil {
return nil, courier.WriteError(w, r, err)
}

msgStatus, found := infobipStatusMapping[ibStatusEnvelop.Results[0].Status.GroupName]
msgStatus, found := infobipStatusMapping[ibStatusEnvelope.Results[0].Status.GroupName]
if !found {
return nil, courier.WriteError(w, r, fmt.Errorf("unknown status '%s', must be one of PENDING, DELIVERED, EXPIRED, REJECTED or UNDELIVERABLE", ibStatusEnvelop.Results[0].Status.GroupName))
return nil, courier.WriteError(w, r, fmt.Errorf("unknown status '%s', must be one of PENDING, DELIVERED, EXPIRED, REJECTED or UNDELIVERABLE", ibStatusEnvelope.Results[0].Status.GroupName))
}

// write our status
status := h.Backend().NewMsgStatusForID(channel, courier.NewMsgID(ibStatusEnvelop.Results[0].MessageID), msgStatus)
status := h.Backend().NewMsgStatusForID(channel, courier.NewMsgID(ibStatusEnvelope.Results[0].MessageID), msgStatus)
err = h.Backend().WriteMsgStatus(status)
if err != nil {
return nil, err
Expand All @@ -73,7 +73,7 @@ var infobipStatusMapping = map[string]courier.MsgStatusValue{
"UNDELIVERABLE": courier.MsgFailed,
}

type ibStatusEnvelop struct {
type ibStatusEnvelope struct {
Results []ibStatus `validate:"required" json:"results"`
}
type ibStatus struct {
Expand Down

0 comments on commit cca9b45

Please sign in to comment.