From 6fb1accbee78ce85394a78a46a7ae5c9469ccbe1 Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 1 Jul 2020 08:36:15 -0300 Subject: [PATCH 1/7] Update IMI Mobile URL for http instead of https --- ivr/imimobile/imi.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ivr/imimobile/imi.go b/ivr/imimobile/imi.go index 6a9f75496..4c46ef44d 100644 --- a/ivr/imimobile/imi.go +++ b/ivr/imimobile/imi.go @@ -304,6 +304,9 @@ func (c *client) PreprocessResume(ctx context.Context, db *sqlx.DB, rp *redis.Po // RequestCall causes this client to request a new outgoing call for this provider func (c *client) RequestCall(client *http.Client, number urns.URN, handleURL string, statusURL string) (ivr.CallID, error) { + handleURL = formatImiUrl(handleURL) + statusURL = formatImiUrl(statusURL) + parseUrl, _ := url.Parse(handleURL) conn := parseUrl.Query().Get("connection") to := formatPhoneNumber(number.Path()) @@ -354,6 +357,11 @@ func (c *client) RequestCall(client *http.Client, number urns.URN, handleURL str return ivr.CallID(call.TransID), nil } +func formatImiUrl(url string) string { + imiUrl := strings.Replace(url, "https", "http", 1) + return imiUrl +} + func formatPhoneNumber(phoneNumber string) string { re := regexp.MustCompile(`([^0-9]+)`) return re.ReplaceAllString(phoneNumber, `$2`) @@ -446,6 +454,7 @@ func (c *client) WriteErrorResponse(w http.ResponseWriter, err error) error { // WriteSessionResponse writes a VXML response for the events in the passed in session func (c *client) WriteSessionResponse(session *models.Session, number urns.URN, resumeURL string, r *http.Request, w http.ResponseWriter) error { + resumeURL = formatImiUrl(resumeURL) // for errored sessions we should just output our error body if session.Status() == models.SessionStatusFailed { return errors.Errorf("cannot write IVR response for errored session") From 19030ac2ba2e72008075d001c5e0036ac99dcbe1 Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 1 Jul 2020 08:40:32 -0300 Subject: [PATCH 2/7] Update URL to support port --- ivr/imimobile/imi.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ivr/imimobile/imi.go b/ivr/imimobile/imi.go index 4c46ef44d..63e769369 100644 --- a/ivr/imimobile/imi.go +++ b/ivr/imimobile/imi.go @@ -359,6 +359,7 @@ func (c *client) RequestCall(client *http.Client, number urns.URN, handleURL str func formatImiUrl(url string) string { imiUrl := strings.Replace(url, "https", "http", 1) + imiUrl = strings.Replace(imiUrl, "rapidpro.ilhasoft.in", "rapidpro.ilhasoft.in:5345") return imiUrl } From 70b4e87e16430074b2d65bcdfb9e4aab39c7984f Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 1 Jul 2020 08:57:05 -0300 Subject: [PATCH 3/7] Fix replace for URL --- ivr/imimobile/imi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ivr/imimobile/imi.go b/ivr/imimobile/imi.go index 63e769369..60a7b172a 100644 --- a/ivr/imimobile/imi.go +++ b/ivr/imimobile/imi.go @@ -359,7 +359,7 @@ func (c *client) RequestCall(client *http.Client, number urns.URN, handleURL str func formatImiUrl(url string) string { imiUrl := strings.Replace(url, "https", "http", 1) - imiUrl = strings.Replace(imiUrl, "rapidpro.ilhasoft.in", "rapidpro.ilhasoft.in:5345") + imiUrl = strings.Replace(imiUrl, "rapidpro.ilhasoft.in", "rapidpro.ilhasoft.in:5345", 1) return imiUrl } From 88183a07983ab4c56347d488b54d162e13461ba1 Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 1 Jul 2020 09:28:40 -0300 Subject: [PATCH 4/7] Update imi mobile port --- ivr/imimobile/imi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ivr/imimobile/imi.go b/ivr/imimobile/imi.go index 60a7b172a..10a4f787f 100644 --- a/ivr/imimobile/imi.go +++ b/ivr/imimobile/imi.go @@ -359,7 +359,7 @@ func (c *client) RequestCall(client *http.Client, number urns.URN, handleURL str func formatImiUrl(url string) string { imiUrl := strings.Replace(url, "https", "http", 1) - imiUrl = strings.Replace(imiUrl, "rapidpro.ilhasoft.in", "rapidpro.ilhasoft.in:5345", 1) + imiUrl = strings.Replace(imiUrl, "rapidpro.ilhasoft.in", "rapidpro.ilhasoft.in:2454", 1) return imiUrl } From fdf15b9a690b50e504db6df9f602ddb37d11358a Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 1 Jul 2020 09:48:39 -0300 Subject: [PATCH 5/7] Remove from resume URL --- ivr/imimobile/imi.go | 1 - 1 file changed, 1 deletion(-) diff --git a/ivr/imimobile/imi.go b/ivr/imimobile/imi.go index 10a4f787f..7667dc95c 100644 --- a/ivr/imimobile/imi.go +++ b/ivr/imimobile/imi.go @@ -455,7 +455,6 @@ func (c *client) WriteErrorResponse(w http.ResponseWriter, err error) error { // WriteSessionResponse writes a VXML response for the events in the passed in session func (c *client) WriteSessionResponse(session *models.Session, number urns.URN, resumeURL string, r *http.Request, w http.ResponseWriter) error { - resumeURL = formatImiUrl(resumeURL) // for errored sessions we should just output our error body if session.Status() == models.SessionStatusFailed { return errors.Errorf("cannot write IVR response for errored session") From e1ef7205fab7ab29295a082c33240f302c806d0d Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 1 Jul 2020 09:59:56 -0300 Subject: [PATCH 6/7] Update resume url to https --- ivr/imimobile/imi.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ivr/imimobile/imi.go b/ivr/imimobile/imi.go index 7667dc95c..c52b49828 100644 --- a/ivr/imimobile/imi.go +++ b/ivr/imimobile/imi.go @@ -455,6 +455,7 @@ func (c *client) WriteErrorResponse(w http.ResponseWriter, err error) error { // WriteSessionResponse writes a VXML response for the events in the passed in session func (c *client) WriteSessionResponse(session *models.Session, number urns.URN, resumeURL string, r *http.Request, w http.ResponseWriter) error { + resumeURL = strings.Replace(resumeURL, "http", "https", 1) // for errored sessions we should just output our error body if session.Status() == models.SessionStatusFailed { return errors.Errorf("cannot write IVR response for errored session") From 08d24966db98a1ee61bccb28797b2d4bc60645fc Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 1 Jul 2020 11:09:39 -0300 Subject: [PATCH 7/7] Update URL to DNS with no https --- ivr/imimobile/imi.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ivr/imimobile/imi.go b/ivr/imimobile/imi.go index c52b49828..d3c8ca965 100644 --- a/ivr/imimobile/imi.go +++ b/ivr/imimobile/imi.go @@ -359,7 +359,7 @@ func (c *client) RequestCall(client *http.Client, number urns.URN, handleURL str func formatImiUrl(url string) string { imiUrl := strings.Replace(url, "https", "http", 1) - imiUrl = strings.Replace(imiUrl, "rapidpro.ilhasoft.in", "rapidpro.ilhasoft.in:2454", 1) + imiUrl = strings.Replace(imiUrl, "rapidpro.ilhasoft.in", "a4ce2456b9181460a81a65c6d8f65a3c-101633647.ap-south-1.elb.amazonaws.com", 1) return imiUrl } @@ -455,7 +455,7 @@ func (c *client) WriteErrorResponse(w http.ResponseWriter, err error) error { // WriteSessionResponse writes a VXML response for the events in the passed in session func (c *client) WriteSessionResponse(session *models.Session, number urns.URN, resumeURL string, r *http.Request, w http.ResponseWriter) error { - resumeURL = strings.Replace(resumeURL, "http", "https", 1) + resumeURL = formatImiUrl(resumeURL) // for errored sessions we should just output our error body if session.Status() == models.SessionStatusFailed { return errors.Errorf("cannot write IVR response for errored session")