Merge pull request #332 in FS/freeswitch from feature/FS-7783-play_and_get_digits-capture-invalid to master

* commit 'eed386bc8d843d01cda4c0ab99382aa3c49f41c5':
  FS-7783 Add channel variable for capturing DTMF input when using play_and_get_digits when the response does not match
This commit is contained in:
William King 2015-07-06 16:22:32 -05:00
commit fb173c9af7
1 changed files with 7 additions and 0 deletions

View File

@ -2174,14 +2174,21 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
if (!(status == SWITCH_STATUS_TOO_SMALL && strlen(digit_buffer) == 0)) {
if (status == SWITCH_STATUS_SUCCESS) {
if (!zstr(digit_buffer)) {
char *invalid_var = NULL;
if (zstr(digits_regex)) {
return SWITCH_STATUS_SUCCESS;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "Test Regex [%s][%s]\n", digit_buffer, digits_regex);
invalid_var = switch_mprintf("%s_invalid", var_name);
if (switch_regex_match(digit_buffer, digits_regex) == SWITCH_STATUS_SUCCESS) {
switch_channel_set_variable(channel, invalid_var, NULL);
switch_safe_free(invalid_var);
return SWITCH_STATUS_SUCCESS;
} else {
switch_channel_set_variable(channel, var_name, NULL);
switch_channel_set_variable(channel, invalid_var, digit_buffer);
switch_safe_free(invalid_var);
}
}
}