Skip to content

Commit

Permalink
more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Aug 22, 2017
1 parent 5b50c0c commit d031787
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions backends/rapidpro/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func (b *backend) WasMsgSent(msg courier.Msg) (bool, error) {
rc := b.redisPool.Get()
defer rc.Close()

todayKey := fmt.Sprintf(sentSetName, time.Now().In(time.UTC).Format("2006_01_02"))
yesterdayKey := fmt.Sprintf(sentSetName, time.Now().Add(time.Hour*-24).In(time.UTC).Format("2006_01_02"))
todayKey := fmt.Sprintf(sentSetName, time.Now().UTC().Format("2006_01_02"))
yesterdayKey := fmt.Sprintf(sentSetName, time.Now().Add(time.Hour*-24).UTC().Format("2006_01_02"))
return redis.Bool(luaSent.Do(rc, todayKey, yesterdayKey, msg.ID().String()))
}

Expand All @@ -123,7 +123,7 @@ func (b *backend) MarkOutgoingMsgComplete(msg courier.Msg, status courier.MsgSta

// mark as sent in redis as well if this was actually wired or sent
if status != nil && (status.Status() == courier.MsgSent || status.Status() == courier.MsgWired) {
dateKey := fmt.Sprintf(sentSetName, time.Now().In(time.UTC).Format("2006_01_02"))
dateKey := fmt.Sprintf(sentSetName, time.Now().UTC().Format("2006_01_02"))
rc.Do("sadd", dateKey, msg.ID().String())
}
}
Expand Down Expand Up @@ -161,8 +161,8 @@ func (b *backend) WriteMsgStatus(status courier.MsgStatus) error {
rc := b.redisPool.Get()
defer rc.Close()

dateKey := fmt.Sprintf(sentSetName, time.Now().In(time.UTC).Format("2006_01_02"))
prevDateKey := fmt.Sprintf(sentSetName, time.Now().Add(time.Hour*-24).In(time.UTC).Format("2006_01_02"))
dateKey := fmt.Sprintf(sentSetName, time.Now().UTC().Format("2006_01_02"))
prevDateKey := fmt.Sprintf(sentSetName, time.Now().Add(time.Hour*-24).UTC().Format("2006_01_02"))

// we pipeline the removals because we don't care about the return value
rc.Send("srem", dateKey, status.ID().String())
Expand Down
5 changes: 3 additions & 2 deletions handlers/kannel/kannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ var defaultSendTestCases = []ChannelSendTestCase{
Text: "Simple Message", URN: "tel:+250788383383", Priority: courier.BulkPriority,
Status: "W",
ResponseBody: "0: Accepted for delivery", ResponseStatus: 200,
URLParams: map[string]string{"text": "Simple Message", "to": "+250788383383", "coding": "", "priority": ""},
SendPrep: setSendURL},
URLParams: map[string]string{"text": "Simple Message", "to": "+250788383383", "coding": "", "priority": "",
"dlr-url": "http://courier.test/c/kn/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/?id=10&status=%d"},
SendPrep: setSendURL},
{Label: "Unicode Send",
Text: "☺", URN: "tel:+250788383383", Priority: courier.BulkPriority,
Status: "W",
Expand Down
2 changes: 1 addition & 1 deletion handlers/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func RunChannelSendTestCases(t *testing.T, channel courier.Channel, handler cour
if testCase.Priority != 0 {
priority = testCase.Priority
}
msg := mb.NewOutgoingMsg(channel, courier.URN(testCase.URN), testCase.Text, priority)
msg := mb.NewOutgoingMsg(channel, courier.NewMsgID(10), courier.URN(testCase.URN), testCase.Text, priority)
for _, a := range testCase.Attachments {
msg.WithAttachment(a)
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/yo/yo.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,5 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) {

}

return status, errors.Errorf("Received error from Yo! API")
return status, errors.Errorf("received error from Yo! API")
}
2 changes: 1 addition & 1 deletion handlers/yo/yo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var getSendTestCases = []ChannelSendTestCase{
{Label: "Errored wrong authorization",
Text: "Simple Message", URN: "tel:+250788383383",
Status: "E",
Error: "Received error from Yo! API",
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},
Expand Down
4 changes: 2 additions & 2 deletions test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func (mb *MockBackend) NewIncomingMsg(channel Channel, urn URN, text string) Msg
}

// NewOutgoingMsg creates a new outgoing message from the given params
func (mb *MockBackend) NewOutgoingMsg(channel Channel, urn URN, text string, priority MsgPriority) Msg {
return &mockMsg{channel: channel, urn: urn, text: text, priority: priority}
func (mb *MockBackend) NewOutgoingMsg(channel Channel, id MsgID, urn URN, text string, priority MsgPriority) Msg {
return &mockMsg{channel: channel, id: id, urn: urn, text: text, priority: priority}
}

// PushOutgoingMsg is a test method to add a message to our queue of messages to send
Expand Down

0 comments on commit d031787

Please sign in to comment.