]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-12022: [mod_event_socket] Add Job-Owner-UUID with session uuid when using bgapi...
authorÍtalo Rossi <italo@evolux.net.br>
Thu, 22 Aug 2019 19:35:34 +0000 (16:35 -0300)
committerÍtalo Rossi <italo@evolux.net.br>
Thu, 22 Aug 2019 19:35:34 +0000 (16:35 -0300)
src/mod/event_handlers/mod_event_socket/mod_event_socket.c

index a9234222cf93959d8be96a309c4d2286e4c8d22c..f0137412d8b14843f88f9bf01737492d3ed46d1e 100644 (file)
@@ -375,6 +375,9 @@ static void event_handler(switch_event_t *event)
                        if (!uuid || (l->session && strcmp(uuid, switch_core_session_get_uuid(l->session)))) {
                                send = 0;
                        }
+                       if (!strcmp(switch_core_session_get_uuid(l->session), switch_event_get_header_nil(event, "Job-Owner-UUID"))) {
+                           send = 1;
+                       }
                }
 
                if (send) {
@@ -1499,6 +1502,7 @@ struct api_command_struct {
        listener_t *listener;
        char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
        int bg;
+       char bg_owner_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
        int ack;
        int console_execute;
        switch_memory_pool_t *pool;
@@ -1557,6 +1561,7 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
 
                if (switch_event_create(&event, SWITCH_EVENT_BACKGROUND_JOB) == SWITCH_STATUS_SUCCESS) {
                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-UUID", acs->uuid_str);
+                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-Owner-UUID", acs->bg_owner_uuid_str);
                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-Command", acs->api_cmd);
                        if (acs->arg) {
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-Command-Arg", acs->arg);
@@ -2357,6 +2362,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
                        switch_uuid_get(&uuid);
                        switch_uuid_format(acs->uuid_str, &uuid);
                }
+               switch_copy_string(acs->bg_owner_uuid_str, switch_core_session_get_uuid(listener->session), sizeof(acs->bg_owner_uuid_str));
                switch_snprintf(reply, reply_len, "~Reply-Text: +OK Job-UUID: %s\nJob-UUID: %s\n\n", acs->uuid_str, acs->uuid_str);
                switch_thread_create(&thread, thd_attr, api_exec, acs, acs->pool);
                sanity = 2000;