]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_python3] Create an event on python_fetch()
authorAdrian Fretwell <adrian.fretwell@topgreen.co.uk>
Tue, 24 Jan 2023 15:14:29 +0000 (15:14 +0000)
committerGitHub <noreply@github.com>
Tue, 24 Jan 2023 15:14:29 +0000 (18:14 +0300)
src/mod/languages/mod_python3/mod_python3.c

index 52a331236102aec1522395ad3e253937e5461b79..ca05f18710f486aa08d43ae1e776554fd0b4272d 100644 (file)
@@ -354,12 +354,24 @@ static switch_xml_t python_fetch(const char *section,
 
        switch_xml_t xml = NULL;
        char *str = NULL;
+       switch_event_t *my_params = NULL;
 
        if (!zstr(globals.xml_handler)) {
                char *mycmd = strdup(globals.xml_handler);
 
                switch_assert(mycmd);
 
+               if (!params) {
+                       switch_event_create(&params, SWITCH_EVENT_REQUEST_PARAMS);
+                       switch_assert(params);
+                       my_params = params;
+               }
+
+               switch_event_add_header_string(params, SWITCH_STACK_TOP, "section", switch_str_nil(section));
+               switch_event_add_header_string(params, SWITCH_STACK_TOP, "tag_name", switch_str_nil(tag_name));
+               switch_event_add_header_string(params, SWITCH_STACK_TOP, "key_name", switch_str_nil(key_name));
+               switch_event_add_header_string(params, SWITCH_STACK_TOP, "key_value", switch_str_nil(key_value));
+
                eval_some_python("xml_fetch", mycmd, NULL, NULL, params, &str, NULL);
 
                if (str) {
@@ -372,6 +384,10 @@ static switch_xml_t python_fetch(const char *section,
                }
 
                free(mycmd);
+
+               if (my_params) {
+                       switch_event_destroy(&my_params);
+               }
        }
 
        return xml;