Skip to content

Commit

Permalink
Merge pull request #110 from Ilhasoft/update/v7.1.0
Browse files Browse the repository at this point in the history
Update/v7.1.0
  • Loading branch information
matmsa27 authored May 30, 2022
2 parents 04a7f5a + 0aa049d commit fee7fb3
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 134 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI
on: [push, pull_request]
env:
go-version: '1.17.x'
redis-version: '3.2.4'
jobs:
test:
name: Test
Expand All @@ -16,7 +17,7 @@ jobs:
- name: Install Redis
uses: zhulik/redis-action@v1.0.0
with:
redis version: '5'
redis version: ${{ env.redis-version }}

- name: Install PostgreSQL
uses: harmon758/postgresql-action@v1
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v7.1.0
----------
* Remove chatbase support
* Test with Redis 3.2.4
* Add support for 'Expired' status in the AT handler

v7.0.0
----------
* Tweak README
Expand Down
4 changes: 4 additions & 0 deletions WENI-CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.2.0-courier-7.1.0
----------
* Merge tag v7.1.0 from nyaruka into our 1.1.8-courier-7.0.0

1.1.8-courier-7.0.0
----------
* Fix whatsapp handler to update the contact URN if the wa_id returned in the send message request is different from the current URN path, avoiding creating a new contact.
Expand Down
16 changes: 0 additions & 16 deletions backends/rapidpro/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/jmoiron/sqlx"
"github.com/nyaruka/courier"
"github.com/nyaruka/courier/batch"
"github.com/nyaruka/courier/chatbase"
"github.com/nyaruka/courier/queue"
"github.com/nyaruka/courier/utils"
"github.com/nyaruka/gocommon/storage"
Expand All @@ -33,11 +32,6 @@ const msgQueueName = "msgs"
// the name of our set for tracking sends
const sentSetName = "msgs_sent_%s"

// constants used in org configs for chatbase
const chatbaseAPIKey = "CHATBASE_API_KEY"
const chatbaseVersion = "CHATBASE_VERSION"
const chatbaseMessageType = "agent"

// our timeout for backend operations
const backendTimeout = time.Second * 20

Expand Down Expand Up @@ -292,16 +286,6 @@ func (b *backend) MarkOutgoingMsgComplete(ctx context.Context, msg courier.Msg,
}
}
}

// if this org has chatbase connected, notify chatbase
chatKey, _ := msg.Channel().OrgConfigForKey(chatbaseAPIKey, "").(string)
if chatKey != "" {
chatVersion, _ := msg.Channel().OrgConfigForKey(chatbaseVersion, "").(string)
err := chatbase.SendChatbaseMessage(chatKey, chatVersion, chatbaseMessageType, dbMsg.ContactID_.String(), msg.Channel().Name(), msg.Text(), time.Now().UTC())
if err != nil {
logrus.WithError(err).WithField("chatbase_api_key", chatKey).WithField("chatbase_version", chatVersion).WithField("msg_id", dbMsg.ID().String()).Error("unable to write chatbase message")
}
}
}

// WriteMsg writes the passed in message to our store
Expand Down
50 changes: 0 additions & 50 deletions chatbase/chatbase.go

This file was deleted.

64 changes: 0 additions & 64 deletions chatbase/chatbase_test.go

This file was deleted.

3 changes: 2 additions & 1 deletion handlers/africastalking/africastalking.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ var statusMapping = map[string]courier.MsgStatusValue{
"Buffered": courier.MsgSent,
"Rejected": courier.MsgFailed,
"Failed": courier.MsgFailed,
"Expired": courier.MsgFailed,
}

// receiveStatus is our HTTP handler function for status updates
Expand All @@ -105,7 +106,7 @@ func (h *handler) receiveStatus(ctx context.Context, channel courier.Channel, w
msgStatus, found := statusMapping[form.Status]
if !found {
return nil, handlers.WriteAndLogRequestError(ctx, h, channel, w, r,
fmt.Errorf("unknown status '%s', must be one of 'Success','Sent','Buffered','Rejected' or 'Failed'", form.Status))
fmt.Errorf("unknown status '%s', must be one of 'Success','Sent','Buffered','Rejected', 'Failed', or 'Expired'", form.Status))
}

// write our status
Expand Down
6 changes: 4 additions & 2 deletions handlers/africastalking/africastalking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var (

missingStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7"
invalidStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7&status=Borked"
validStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7&status=Success"
successStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7&status=Success"
expiredStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7&status=Expired"
)

var testCases = []ChannelHandleTestCase{
Expand All @@ -42,7 +43,8 @@ var testCases = []ChannelHandleTestCase{
{Label: "Invalid Date", URL: receiveURL, Data: invalidDate, Status: 400, Response: "invalid date format"},
{Label: "Status Invalid", URL: statusURL, Status: 400, Data: invalidStatus, Response: "unknown status"},
{Label: "Status Missing", URL: statusURL, Status: 400, Data: missingStatus, Response: "field 'status' required"},
{Label: "Status Valid", URL: statusURL, Status: 200, Data: validStatus, Response: `"status":"D"`},
{Label: "Status Success", URL: statusURL, Status: 200, Data: successStatus, Response: `"status":"D"`},
{Label: "Status Expired", URL: statusURL, Status: 200, Data: expiredStatus, Response: `"status":"F"`},
}

func TestHandler(t *testing.T) {
Expand Down

0 comments on commit fee7fb3

Please sign in to comment.