[mod_kazoo] recurse context runtime vars
This commit is contained in:
parent
647ed310e5
commit
3c6d47c293
|
@ -340,17 +340,7 @@ static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *s
|
||||||
|
|
||||||
// add runtime vars to event for expand
|
// add runtime vars to event for expand
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
cJSON *item = NULL;
|
kz_expand_json_to_event(ctx, event, "kz_ctx");
|
||||||
char *response = NULL;
|
|
||||||
cJSON_ArrayForEach(item, ctx) {
|
|
||||||
if (item->type == cJSON_String) {
|
|
||||||
response = strdup(item->valuestring);
|
|
||||||
} else {
|
|
||||||
response = cJSON_PrintUnformatted(item);
|
|
||||||
}
|
|
||||||
kz_switch_event_add_variable_name_printf(event, SWITCH_STACK_BOTTOM, response, "kz_ctx_%s", item->string);
|
|
||||||
switch_safe_free(response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d_dest = kz_event_expand_headers(event, dest);
|
d_dest = kz_event_expand_headers(event, dest);
|
||||||
|
|
|
@ -516,6 +516,32 @@ SWITCH_DECLARE(switch_status_t) kz_switch_event_add_variable_name_printf(switch_
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_status_t) kz_expand_json_to_event(cJSON *json, switch_event_t *event, char * prefix)
|
||||||
|
{
|
||||||
|
char * fmt = switch_mprintf("%s%s%%s", prefix ? prefix : "", prefix ? "_" : "");
|
||||||
|
if (event) {
|
||||||
|
cJSON *item = NULL;
|
||||||
|
char *response = NULL;
|
||||||
|
cJSON_ArrayForEach(item, json) {
|
||||||
|
if (item->type == cJSON_String) {
|
||||||
|
response = strdup(item->valuestring);
|
||||||
|
} else if (item->type == cJSON_Object) {
|
||||||
|
char * fmt1 = switch_mprintf(fmt, item->string);
|
||||||
|
kz_expand_json_to_event(item, event, fmt1);
|
||||||
|
switch_safe_free(fmt1);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
response = cJSON_PrintUnformatted(item);
|
||||||
|
}
|
||||||
|
kz_switch_event_add_variable_name_printf(event, SWITCH_STACK_BOTTOM, response, fmt, item->string);
|
||||||
|
switch_safe_free(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_safe_free(fmt);
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_xml_t) kz_xml_child(switch_xml_t xml, const char *name)
|
SWITCH_DECLARE(switch_xml_t) kz_xml_child(switch_xml_t xml, const char *name)
|
||||||
{
|
{
|
||||||
xml = (xml) ? xml->child : NULL;
|
xml = (xml) ? xml->child : NULL;
|
||||||
|
|
|
@ -48,4 +48,6 @@ void kz_expand_headers_self(switch_event_t *event);
|
||||||
char * kz_expand_vars_pool(char *xml_str, switch_memory_pool_t *pool);
|
char * kz_expand_vars_pool(char *xml_str, switch_memory_pool_t *pool);
|
||||||
switch_status_t kz_json_api(const char * command, cJSON *args, cJSON **res);
|
switch_status_t kz_json_api(const char * command, cJSON *args, cJSON **res);
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_status_t) kz_expand_json_to_event(cJSON *json, switch_event_t *event, char * prefix);
|
||||||
|
|
||||||
KZ_END_EXTERN_C
|
KZ_END_EXTERN_C
|
||||||
|
|
Loading…
Reference in New Issue