Add support for presence_disable_early in sofia_dialog_probe_callback

Addresses scenario where a SUBSCRIBE messages triggers a presence probe while a call with the presence_disable_early variable set or on a profile with the flag PFLAG_PRESENCE_DISABLE_EARLY set is in the early state.

This changes the behavior to skip the relevant channel when the profile has the flag set or the channel has the variable set, so it will not send the NOTIFY with the early state in response to the presence probe.
This commit is contained in:
Justin-lavelle 2025-01-16 16:18:01 -08:00
parent e343b47c49
commit f660112409
1 changed files with 18 additions and 0 deletions

View File

@ -1954,6 +1954,7 @@ static int sofia_dialog_probe_callback(void *pArg, int argc, char **argv, char *
char *from_tag = switch_str_nil(argv[15]);
char *orig_proto = switch_str_nil(argv[16]);
switch_core_session_t *session;
const char *event_status = "";
char *data = NULL, *tmp;
char key[256] = "";
@ -1968,6 +1969,7 @@ static int sofia_dialog_probe_callback(void *pArg, int argc, char **argv, char *
int bInternal = 0;
int i;
int skip_proto = 0;
int skip_dialog = 0;
if (mod_sofia_globals.debug_presence > 1) {
for (i = 0; i < argc; i++) {
@ -1980,6 +1982,22 @@ static int sofia_dialog_probe_callback(void *pArg, int argc, char **argv, char *
return 0;
}
// If the dialog is in the "early" state check the presence_disable_early profile flag and channel variable.
// When presence_disable_early is set the dialog should not influence the result of the probe and resulting NOTIFY that is sent.
if (!strcasecmp(state, "early") && (session = switch_core_session_locate(uuid))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
if (sofia_test_pflag(h->profile, PFLAG_PRESENCE_DISABLE_EARLY) ||
switch_true(switch_channel_get_variable(channel, "presence_disable_early"))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sofia_dialog_probe_callback: presence_disable_early is set skipping dialog\n");
skip_dialog = 1;
}
switch_core_session_rwunlock(session);
if (skip_dialog) return 0;
}
// Usually we report the dialogs FROM the probed user. The exception is when the monitored endpoint is internal,
// and its presence_id is set in the dialplan. Reverse the direction if this is not a registered entity.
if (!strcmp(direction, "inbound") && strcmp(user, from_user) ) {