-
Notifications
You must be signed in to change notification settings - Fork 71
Set HX user_data parameter as flow name #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
3c8c801
04bd755
dccf0dc
6291758
950141d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,14 +57,35 @@ var defaultSendTestCases = []ChannelSendTestCase{ | |
Text: "Simple Message", | ||
URN: "tel:+250788383383", | ||
Status: "W", | ||
Flow: &struct { | ||
UUID string | ||
Name string | ||
}{UUID: "9de3663f-c5c5-4c92-9f45-ecbc09abcc85", Name: "Favorites"}, | ||
URLParams: map[string]string{ | ||
"accountid": "Username", | ||
"password": "Password", | ||
"text": "Simple Message", | ||
"to": "+250788383383", | ||
"ret_id": "10", | ||
"datacoding": "8", | ||
"userdata": "textit", | ||
"user_data": "Favorites", | ||
"ret_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/status", | ||
"ret_mo_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive", | ||
}, | ||
ResponseStatus: 200, | ||
SendPrep: setSendURL}, | ||
{Label: "Plain Send without flow", | ||
Text: "Simple Message", | ||
URN: "tel:+250788383383", | ||
Status: "W", | ||
URLParams: map[string]string{ | ||
"accountid": "Username", | ||
"password": "Password", | ||
"text": "Simple Message", | ||
"to": "+250788383383", | ||
"ret_id": "10", | ||
"datacoding": "8", | ||
"user_data": "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A message not from a flow will have the user_data as empty string |
||
"ret_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/status", | ||
"ret_mo_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive", | ||
}, | ||
|
@@ -74,14 +95,18 @@ var defaultSendTestCases = []ChannelSendTestCase{ | |
Text: "☺", | ||
URN: "tel:+250788383383", | ||
Status: "W", | ||
Flow: &struct { | ||
UUID string | ||
Name string | ||
}{UUID: "9de3663f-c5c5-4c92-9f45-ecbc09abcc85", Name: "Favorites"}, | ||
URLParams: map[string]string{ | ||
"accountid": "Username", | ||
"password": "Password", | ||
"text": "☺", | ||
"to": "+250788383383", | ||
"ret_id": "10", | ||
"datacoding": "8", | ||
"userdata": "textit", | ||
"user_data": "Favorites", | ||
"ret_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/status", | ||
"ret_mo_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive", | ||
}, | ||
|
@@ -91,14 +116,18 @@ var defaultSendTestCases = []ChannelSendTestCase{ | |
Text: "This is a longer message than 160 characters and will cause us to split it into two separate parts, isn't that right but it is even longer than before I say, I need to keep adding more things to make it work", | ||
URN: "tel:+250788383383", | ||
Status: "W", | ||
Flow: &struct { | ||
UUID string | ||
Name string | ||
}{UUID: "9de3663f-c5c5-4c92-9f45-ecbc09abcc85", Name: "Favorites"}, | ||
URLParams: map[string]string{ | ||
"accountid": "Username", | ||
"password": "Password", | ||
"text": "I need to keep adding more things to make it work", | ||
"to": "+250788383383", | ||
"ret_id": "10", | ||
"datacoding": "8", | ||
"userdata": "textit", | ||
"user_data": "Favorites", | ||
"ret_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/status", | ||
"ret_mo_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive", | ||
}, | ||
|
@@ -109,14 +138,18 @@ var defaultSendTestCases = []ChannelSendTestCase{ | |
Attachments: []string{"image/jpeg:https://foo.bar/image.jpg"}, | ||
URN: "tel:+250788383383", | ||
Status: "W", | ||
Flow: &struct { | ||
UUID string | ||
Name string | ||
}{UUID: "9de3663f-c5c5-4c92-9f45-ecbc09abcc85", Name: "Favorites"}, | ||
URLParams: map[string]string{ | ||
"accountid": "Username", | ||
"password": "Password", | ||
"text": "My pic!\nhttps://foo.bar/image.jpg", | ||
"to": "+250788383383", | ||
"ret_id": "10", | ||
"datacoding": "8", | ||
"userdata": "textit", | ||
"user_data": "Favorites", | ||
"ret_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/status", | ||
"ret_mo_url": "https://localhost/c/hx/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive", | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,10 @@ type ChannelSendTestCase struct { | |
HighPriority bool | ||
ResponseToExternalID string | ||
Metadata json.RawMessage | ||
Flow *struct { | ||
UUID string | ||
Name string | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use the |
||
|
||
ResponseStatus int | ||
ResponseBody string | ||
|
@@ -231,6 +235,10 @@ func RunChannelSendTestCases(t *testing.T, channel courier.Channel, handler cour | |
if len(testCase.Metadata) > 0 { | ||
msg.WithMetadata(testCase.Metadata) | ||
} | ||
if testCase.Flow != nil { | ||
var flowRef = courier.MsgFlowRef{UUID: testCase.Flow.UUID, Name: testCase.Flow.Name} | ||
msg.WithFlow(flowRef) | ||
} | ||
|
||
var testRequest *http.Request | ||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,13 @@ func NewMsgUUIDFromString(uuidString string) MsgUUID { | |
return MsgUUID{uuid} | ||
} | ||
|
||
type MsgFlowRef struct { | ||
UUID string `json:"uuid" validate:"uuid4"` | ||
Name string `json:"name"` | ||
} | ||
|
||
var NilMsgFlowRef = MsgFlowRef{"", ""} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to serialize messages with While you're changing this let's call it just |
||
|
||
//----------------------------------------------------------------------------- | ||
// Msg interface | ||
//----------------------------------------------------------------------------- | ||
|
@@ -98,6 +105,8 @@ type Msg interface { | |
ResponseToExternalID() string | ||
IsResend() bool | ||
|
||
Flow() MsgFlowRef | ||
|
||
Channel() Channel | ||
|
||
ReceivedOn() *time.Time | ||
|
@@ -113,6 +122,7 @@ type Msg interface { | |
WithAttachment(url string) Msg | ||
WithURNAuth(auth string) Msg | ||
WithMetadata(metadata json.RawMessage) Msg | ||
WithFlow(flow MsgFlowRef) Msg | ||
|
||
EventID() int64 | ||
SessionStatus() string | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
FlowReference
type