From 759783532dc7c34b4f8ab27e63438a350bfbc256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dtalo=20Rossi?= Date: Thu, 22 Aug 2019 16:35:34 -0300 Subject: [PATCH] FS-12022: [mod_event_socket] Add Job-Owner-UUID with session uuid when using bgapi inside outbound socket --- src/mod/event_handlers/mod_event_socket/mod_event_socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index a9234222cf..f0137412d8 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -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;