From 0a668db1d56c95a1fc6e2e92957e01055a54872b Mon Sep 17 00:00:00 2001 From: Nic Pottier Date: Wed, 23 Aug 2017 12:09:31 -0500 Subject: [PATCH] Have shaqodoon ignore invalid certs, dont create status if sender already did --- handlers/shaqodoon/shaqodoon.go | 2 +- responses.go | 4 ++-- sender.go | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/handlers/shaqodoon/shaqodoon.go b/handlers/shaqodoon/shaqodoon.go index a8a359d5a..3a3e4336f 100644 --- a/handlers/shaqodoon/shaqodoon.go +++ b/handlers/shaqodoon/shaqodoon.go @@ -179,7 +179,7 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) { req, err := http.NewRequest(http.MethodGet, sendURL, nil) req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - rr, err := utils.MakeHTTPRequest(req) + rr, err := utils.MakeInsecureHTTPRequest(req) status := h.Backend().NewMsgStatusForID(msg.Channel(), msg.ID(), courier.MsgErrored) status.AddLog(courier.NewChannelLogFromRR(msg.Channel(), msg.ID(), rr)) diff --git a/responses.go b/responses.go index b3efcaaf3..989f7a142 100644 --- a/responses.go +++ b/responses.go @@ -30,7 +30,7 @@ func WriteError(w http.ResponseWriter, r *http.Request, err error) error { // WriteIgnored writes a JSON response for the passed in message func WriteIgnored(w http.ResponseWriter, r *http.Request, message string) error { - lg.Log(r.Context()).Info("ignored message") + lg.Log(r.Context()).Info("msg ignored") return writeData(w, http.StatusOK, message, struct{}{}) } @@ -43,7 +43,7 @@ func WriteReceiveSuccess(w http.ResponseWriter, r *http.Request, msg Msg) error "msg_urn": msg.URN().Identity(), "msg_text": msg.Text(), "msg_attachments": msg.Attachments(), - }).Info("message received") + }).Info("msg received") return writeData(w, http.StatusOK, "Message Accepted", &receiveData{msg.UUID()}) } diff --git a/sender.go b/sender.go index 301901793..ff5b61425 100644 --- a/sender.go +++ b/sender.go @@ -131,7 +131,7 @@ func (w *Sender) Send() { w.foreman.server.WaitGroup().Add(1) defer w.foreman.server.WaitGroup().Done() - log := logrus.WithField("comp", "sender").WithField("senderID", w.id) + log := logrus.WithField("comp", "sender").WithField("sender_id", w.id) log.Debug("started") server := w.foreman.server @@ -174,7 +174,10 @@ func (w *Sender) Send() { secondDuration := float64(duration) / float64(time.Second) if err != nil { - status = backend.NewMsgStatusForID(msg.Channel(), msg.ID(), MsgErrored) + // sender didn't give us a status, build one ourselves + if status == nil { + status = backend.NewMsgStatusForID(msg.Channel(), msg.ID(), MsgErrored) + } msgLog.WithError(err).WithField("elapsed", duration).Error("msg errored") librato.Default.AddGauge(fmt.Sprintf("courier.msg_send_error_%s", msg.Channel().ChannelType()), secondDuration) } else {