[mod_callcenter] fix NOTIFY gets sent to all subscriptions on PRESENCE_PROBE

This commit is contained in:
agree 2024-06-04 13:53:02 -04:00
parent 218a00e2e9
commit c3ffcbcf6c
1 changed files with 9 additions and 5 deletions

View File

@ -484,7 +484,7 @@ struct cc_queue {
}; };
typedef struct cc_queue cc_queue_t; typedef struct cc_queue cc_queue_t;
static void cc_send_presence(const char *queue_name); static void cc_send_presence(const char *queue_name, const char *call_id);
static void free_queue(cc_queue_t *queue) static void free_queue(cc_queue_t *queue)
{ {
@ -3155,7 +3155,7 @@ SWITCH_STANDARD_APP(callcenter_function)
/* Send Event with queue count */ /* Send Event with queue count */
cc_queue_count(queue_name); cc_queue_count(queue_name);
cc_send_presence(queue_name); cc_send_presence(queue_name, NULL);
/* Start Thread that will playback different prompt to the channel */ /* Start Thread that will playback different prompt to the channel */
switch_core_new_memory_pool(&pool); switch_core_new_memory_pool(&pool);
@ -3314,7 +3314,7 @@ SWITCH_STANDARD_APP(callcenter_function)
/* Send Event with queue count */ /* Send Event with queue count */
cc_queue_count(queue_name); cc_queue_count(queue_name);
cc_send_presence(queue_name); cc_send_presence(queue_name, NULL);
end: end:
@ -3378,7 +3378,7 @@ SWITCH_STANDARD_APP(callcenter_track)
return; return;
} }
static void cc_send_presence(const char *queue_name) { static void cc_send_presence(const char *queue_name, const char *call_id) {
char *sql; char *sql;
char res[256] = ""; char res[256] = "";
int count = 0; int count = 0;
@ -3409,6 +3409,9 @@ static void cc_send_presence(const char *queue_name) {
switch_event_add_header_string(send_event, SWITCH_STACK_BOTTOM, "unique-id", queue_name); switch_event_add_header_string(send_event, SWITCH_STACK_BOTTOM, "unique-id", queue_name);
switch_event_add_header_string(send_event, SWITCH_STACK_BOTTOM, "answer-state", count > 0 ? "confirmed" : "terminated"); switch_event_add_header_string(send_event, SWITCH_STACK_BOTTOM, "answer-state", count > 0 ? "confirmed" : "terminated");
switch_event_add_header_string(send_event, SWITCH_STACK_BOTTOM, "presence-call-direction", "inbound"); switch_event_add_header_string(send_event, SWITCH_STACK_BOTTOM, "presence-call-direction", "inbound");
if (call_id) {
switch_event_add_header_string(send_event, SWITCH_STACK_BOTTOM, "call-id", call_id);
}
switch_event_fire(&send_event); switch_event_fire(&send_event);
} else { } else {
@ -3419,6 +3422,7 @@ static void cc_send_presence(const char *queue_name) {
static void cc_presence_event_handler(switch_event_t *event) { static void cc_presence_event_handler(switch_event_t *event) {
char *to = switch_event_get_header(event, "to"); char *to = switch_event_get_header(event, "to");
const char *call_id = switch_event_get_header(event, "sub-call-id");
char *dup_to = NULL, *queue_name; char *dup_to = NULL, *queue_name;
cc_queue_t *queue; cc_queue_t *queue;
@ -3440,7 +3444,7 @@ static void cc_presence_event_handler(switch_event_t *event) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Queue not found, exit!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Queue not found, exit!\n");
return; return;
} }
cc_send_presence(queue_name); cc_send_presence(queue_name, call_id);
queue_rwunlock(queue); queue_rwunlock(queue);
switch_safe_free(dup_to); switch_safe_free(dup_to);
return; return;