Skip to content

Commit c3ed746

Browse files
committed
Update payloads for tasks queued to mailroom
1 parent 220fcd3 commit c3ed746

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

Diff for: backends/rapidpro/backend_test.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (ts *BackendTestSuite) TestDeleteMsgByExternalID() {
189189
err = ts.b.DeleteMsgByExternalID(ctx, knChannel, "ext2")
190190
ts.Nil(err)
191191

192-
ts.assertQueuedContactTask(ContactID(100), "msg_deleted", map[string]any{"org_id": float64(1), "msg_id": float64(10002)})
192+
ts.assertQueuedContactTask(ContactID(100), "msg_deleted", map[string]any{"msg_id": float64(10002)})
193193
}
194194

195195
func (ts *BackendTestSuite) TestContact() {
@@ -1169,8 +1169,6 @@ func (ts *BackendTestSuite) TestWriteMsg() {
11691169
ts.NoError(err)
11701170

11711171
ts.assertQueuedContactTask(msg.ContactID_, "msg_event", map[string]any{
1172-
"contact_id": float64(contact.ID_),
1173-
"org_id": float64(1),
11741172
"channel_id": float64(10),
11751173
"msg_id": float64(msg.ID_),
11761174
"msg_uuid": string(msg.UUID()),
@@ -1335,13 +1333,13 @@ func (ts *BackendTestSuite) TestMailroomEvents() {
13351333
ts.Equal(contact.URNID_, dbE.ContactURNID_)
13361334

13371335
ts.assertQueuedContactTask(contact.ID_, "referral", map[string]any{
1336+
"event_id": float64(dbE.ID_),
1337+
"event_type": "referral",
13381338
"channel_id": float64(10),
1339-
"contact_id": float64(contact.ID_),
1339+
"urn_id": float64(contact.URNID_),
13401340
"extra": map[string]any{"ref_id": "12345"},
1341-
"new_contact": contact.IsNew_,
1341+
"new_contact": false,
13421342
"occurred_on": "2020-08-05T13:30:00.123456789Z",
1343-
"org_id": float64(1),
1344-
"urn_id": float64(contact.URNID_),
13451343
})
13461344
}
13471345

Diff for: backends/rapidpro/task.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ import (
1212
func queueMsgHandling(rc redis.Conn, c *Contact, m *Msg) error {
1313
channel := m.Channel().(*Channel)
1414

15-
// queue to mailroom
1615
body := map[string]any{
17-
"contact_id": c.ID_,
18-
"org_id": channel.OrgID_,
1916
"channel_id": channel.ID_,
2017
"msg_id": m.ID_,
2118
"msg_uuid": m.UUID(),
@@ -32,15 +29,18 @@ func queueMsgHandling(rc redis.Conn, c *Contact, m *Msg) error {
3229

3330
func queueChannelEvent(rc redis.Conn, c *Contact, e *ChannelEvent) error {
3431
body := map[string]any{
35-
"org_id": e.OrgID_,
36-
"contact_id": e.ContactID_,
32+
"event_id": e.ID_,
33+
"event_type": e.EventType_,
3734
"urn_id": e.ContactURNID_,
3835
"channel_id": e.ChannelID_,
3936
"extra": e.Extra(),
4037
"new_contact": c.IsNew_,
4138
"occurred_on": e.OccurredOn_,
4239
"created_on": e.CreatedOn_,
4340
}
41+
if e.OptInID_ != 0 {
42+
body["optin_id"] = e.OptInID_
43+
}
4444

4545
switch e.EventType() {
4646
case courier.EventTypeStopContact:
@@ -61,7 +61,7 @@ func queueChannelEvent(rc redis.Conn, c *Contact, e *ChannelEvent) error {
6161
}
6262

6363
func queueMsgDeleted(rc redis.Conn, ch *Channel, msgID courier.MsgID, contactID ContactID) error {
64-
return queueMailroomTask(rc, "msg_deleted", ch.OrgID_, contactID, map[string]any{"org_id": ch.OrgID_, "msg_id": msgID})
64+
return queueMailroomTask(rc, "msg_deleted", ch.OrgID_, contactID, map[string]any{"msg_id": msgID})
6565
}
6666

6767
// queueMailroomTask queues the passed in task to mailroom. Mailroom processes both messages and

0 commit comments

Comments
 (0)