diff --git a/ivr/imimobile/imi.go b/ivr/imimobile/imi.go index 6a9f75496..d3c8ca965 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,12 @@ 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) + imiUrl = strings.Replace(imiUrl, "rapidpro.ilhasoft.in", "a4ce2456b9181460a81a65c6d8f65a3c-101633647.ap-south-1.elb.amazonaws.com", 1) + return imiUrl +} + func formatPhoneNumber(phoneNumber string) string { re := regexp.MustCompile(`([^0-9]+)`) return re.ReplaceAllString(phoneNumber, `$2`) @@ -446,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 = 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")