diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 3b73913510..351f1d87d5 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -571,13 +571,15 @@ static int sofia_presence_dialog_callback(void *pArg, int argc, char **argv, cha struct dialog_helper *helper = (struct dialog_helper *) pArg; if (argc == 3) { - switch_set_string(helper->status, argv[0]); - switch_set_string(helper->rpid, argv[1]); - switch_set_string(helper->presence_id, argv[2]); + if (!helper->hits) { + switch_set_string(helper->status, argv[0]); + switch_set_string(helper->rpid, argv[1]); + switch_set_string(helper->presence_id, argv[2]); + } helper->hits++; } - return -1; + return 0; } @@ -856,6 +858,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) char *call_info_state = switch_event_get_header(event, "presence-call-info-state"); switch_console_callback_match_t *matches; struct presence_helper helper = { 0 }; + int hup = 0; if (!mod_sofia_globals.running) { return; @@ -877,6 +880,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) if (status && switch_stristr("CS_HANGUP", status)) { status = "Available"; + hup = 1; } if (rpid) { @@ -1091,6 +1095,11 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_dialog_callback, &dh); switch_safe_free(sql); + + if (hup && dh.hits > 0) { + goto done; + } + if (zstr(call_id) && (dh.hits && presence_source && (!strcasecmp(presence_source, "register") || switch_stristr("register", status)))) { goto done; diff --git a/src/switch_channel.c b/src/switch_channel.c index df3bedeacf..617c7f58b5 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -620,10 +620,6 @@ SWITCH_DECLARE(void) switch_channel_perform_presence(switch_channel_t *channel, call_info = switch_channel_get_variable(channel, "presence_call_info"); if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) { - if (!strcasecmp(status, "CS_HANGUP")) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "refresh", "true"); - } - switch_channel_event_set_data(channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "any"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", __FILE__);