From 7794f2223c3d1c06837882263221191a20e097d6 Mon Sep 17 00:00:00 2001 From: Joseph Nadiv Date: Thu, 4 Nov 2021 12:25:52 -0400 Subject: [PATCH] [mod_sofia] Include Callee ID name in presence NOTIFY Retreive user_data from the switch to display the callee ID name on the endpoint receiving the NOTIFY if it is available Fixes #1410 --- src/mod/endpoints/mod_sofia/sofia_presence.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 00cc8561d6..bfb838ae5f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -2986,13 +2986,27 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * } if (!strcasecmp(astate, "early") || !strcasecmp(astate, "confirmed")) { + char *cmd; + char *callee_id_name = NULL; + switch_stream_handle_t user_data_stream = { 0 }; clean_to_user = switch_mprintf("%s", sub_to_user ? sub_to_user : to_user); clean_from_user = switch_mprintf("%s", from_id ? from_id : from_user); + SWITCH_STANDARD_STREAM(user_data_stream); + cmd = switch_mprintf("%s@%s var effective_caller_id_name", clean_to_user, host); + if (switch_api_execute("user_data", cmd, NULL, &user_data_stream) == SWITCH_STATUS_SUCCESS) { + if (strncmp("-ERR", user_data_stream.data, 4)) { + callee_id_name = (char *)user_data_stream.data; + } + } + + switch_safe_free(cmd); + if (is_dialog) { if (!zstr(clean_to_user) && !zstr(clean_from_user)) { - stream.write_function(&stream, "\nsip:%s@%s\n", clean_to_user, clean_to_user, host); + stream.write_function(&stream, "\nsip:%s@%s\n", + zstr(callee_id_name) ? clean_to_user : callee_id_name, clean_to_user, host); stream.write_function(&stream, "\n", clean_to_user, host); stream.write_function(&stream, "\n", holding ? "no" : "yes"); @@ -3062,6 +3076,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * switch_safe_free(clean_to_user); switch_safe_free(clean_from_user); + switch_safe_free(user_data_stream.data); } if (is_dialog) { stream.write_function(&stream, "\n");