FS-5841 --resolve
This commit is contained in:
parent
4129adc9ac
commit
726b607667
|
@ -1724,7 +1724,7 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
|
|||
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
switch_assert(my_params);
|
||||
|
||||
status = switch_xml_locate_user_merged("id", vm_cc, cbt->domain, NULL, &x_user, my_params);
|
||||
status = switch_xml_locate_user_merged("id:number-alias", vm_cc, cbt->domain, NULL, &x_user, my_params);
|
||||
switch_event_destroy(&my_params);
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -2440,7 +2440,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
|
|||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "destination_number", caller_profile->destination_number);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "caller_id_number", caller_id_number);
|
||||
|
||||
if (switch_xml_locate_user_merged("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
|
||||
if (switch_xml_locate_user_merged("id:number-alias", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
|
||||
&x_user, params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", myid, domain_name);
|
||||
ok = 0;
|
||||
|
@ -3388,7 +3388,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
|
|||
switch_assert(locate_params);
|
||||
switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "action", "voicemail-lookup");
|
||||
|
||||
if (switch_xml_locate_user_merged("id", id, domain_name, switch_channel_get_variable(channel, "network_addr"),
|
||||
if (switch_xml_locate_user_merged("id:number-alias", id, domain_name, switch_channel_get_variable(channel, "network_addr"),
|
||||
&x_user, locate_params) == SWITCH_STATUS_SUCCESS) {
|
||||
id = switch_core_session_strdup(session, switch_xml_attr(x_user, "id"));
|
||||
|
||||
|
@ -5689,7 +5689,7 @@ SWITCH_STANDARD_API(vm_fsdb_auth_login_function)
|
|||
}
|
||||
|
||||
switch_event_create(¶ms, SWITCH_EVENT_GENERAL);
|
||||
if (switch_xml_locate_user_merged("id", id, domain, NULL, &x_user, params) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_xml_locate_user_merged("id:number-alias", id, domain, NULL, &x_user, params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", id, domain);
|
||||
stream->write_function(stream, "-ERR User not found\n");
|
||||
} else {
|
||||
|
|
|
@ -2044,34 +2044,52 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_user_merged(const char *key, c
|
|||
{
|
||||
switch_xml_t xml, domain, group, x_user, x_user_dup;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
char *kdup = NULL;
|
||||
char *keys[10] = {0};
|
||||
int i, nkeys;
|
||||
|
||||
if ((status = switch_xml_locate_user_cache(key, user_name, domain_name, &x_user)) == SWITCH_STATUS_SUCCESS) {
|
||||
*user = x_user;
|
||||
} else if ((status = switch_xml_locate_user(key, user_name, domain_name, ip, &xml, &domain, &x_user, &group, params)) == SWITCH_STATUS_SUCCESS) {
|
||||
const char *cacheable = NULL;
|
||||
|
||||
x_user_dup = switch_xml_dup(x_user);
|
||||
switch_xml_merge_user(x_user_dup, domain, group);
|
||||
|
||||
cacheable = switch_xml_attr(x_user_dup, "cacheable");
|
||||
if (switch_true(cacheable)) {
|
||||
switch_time_t expires = 0;
|
||||
switch_time_t time_now = 0;
|
||||
|
||||
if (switch_is_number(cacheable)) {
|
||||
int cache_ms = atol(cacheable);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "caching lookup for user %s@%s for %d milliseconds\n", user_name, domain_name, cache_ms);
|
||||
time_now = switch_micro_time_now();
|
||||
expires = time_now + (cache_ms * 1000);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "caching lookup for user %s@%s indefinitely\n", user_name, domain_name);
|
||||
}
|
||||
switch_xml_user_cache(key, user_name, domain_name, x_user_dup, expires);
|
||||
}
|
||||
*user = x_user_dup;
|
||||
switch_xml_free(xml);
|
||||
if (strchr(key, ':')) {
|
||||
kdup = strdup(key);
|
||||
nkeys = switch_split(kdup, ':', keys);
|
||||
} else {
|
||||
keys[0] = (char *)key;
|
||||
nkeys = 1;
|
||||
}
|
||||
|
||||
for(i = 0; i < nkeys; i++) {
|
||||
if ((status = switch_xml_locate_user_cache(keys[i], user_name, domain_name, &x_user)) == SWITCH_STATUS_SUCCESS) {
|
||||
*user = x_user;
|
||||
break;
|
||||
} else if ((status = switch_xml_locate_user(keys[i], user_name, domain_name, ip, &xml, &domain, &x_user, &group, params)) == SWITCH_STATUS_SUCCESS) {
|
||||
const char *cacheable = NULL;
|
||||
|
||||
x_user_dup = switch_xml_dup(x_user);
|
||||
switch_xml_merge_user(x_user_dup, domain, group);
|
||||
|
||||
cacheable = switch_xml_attr(x_user_dup, "cacheable");
|
||||
if (switch_true(cacheable)) {
|
||||
switch_time_t expires = 0;
|
||||
switch_time_t time_now = 0;
|
||||
|
||||
if (switch_is_number(cacheable)) {
|
||||
int cache_ms = atol(cacheable);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "caching lookup for user %s@%s for %d milliseconds\n",
|
||||
user_name, domain_name, cache_ms);
|
||||
time_now = switch_micro_time_now();
|
||||
expires = time_now + (cache_ms * 1000);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "caching lookup for user %s@%s indefinitely\n", user_name, domain_name);
|
||||
}
|
||||
switch_xml_user_cache(keys[i], user_name, domain_name, x_user_dup, expires);
|
||||
}
|
||||
*user = x_user_dup;
|
||||
switch_xml_free(xml);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch_safe_free(kdup);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue