Skip to content
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

Update IMI Mobile URL for http instead of https #26

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ivr/imimobile/imi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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`)
Expand Down Expand Up @@ -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")
Expand Down