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) {
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;
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"));
}
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 {
{
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 (strchr(key, ':')) {
+ kdup = strdup(key);
+ nkeys = switch_split(kdup, ':', keys);
+ } else {
+ keys[0] = (char *)key;
+ nkeys = 1;
+ }
- 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);
+ 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);
}
- switch_xml_user_cache(key, user_name, domain_name, x_user_dup, expires);
+ *user = x_user_dup;
+ switch_xml_free(xml);
+ break;
}
- *user = x_user_dup;
- switch_xml_free(xml);
}
+ switch_safe_free(kdup);
+
return status;
}