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 14:13:12 -07:00
parent 08c7a1de34
commit eed386bc8d
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);
}
}
}