From cc67ca0a66cbbb2b0c1abf207786eafd3238aa55 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthony.minessale@gmail.com>
Date: Wed, 11 Mar 2009 13:15:02 +0000
Subject: [PATCH] still use intended caller id domain in rpid even when from
 uri is overridden

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12563 d0543943-73ff-0310-b7d9-9358b9ac24b2
---
 src/mod/endpoints/mod_sofia/sofia_glue.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c
index f733eaadb0..eb10805379 100644
--- a/src/mod/endpoints/mod_sofia/sofia_glue.c
+++ b/src/mod/endpoints/mod_sofia/sofia_glue.c
@@ -1202,7 +1202,12 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
 			use_from_str = tech_pvt->from_str;
 		}
 
-		rpid_domain = switch_core_session_strdup(session, use_from_str);
+		if (!switch_strlen_zero(tech_pvt->gateway_from_str)) {
+			rpid_domain = switch_core_session_strdup(session, tech_pvt->gateway_from_str);
+		} else if (!switch_strlen_zero(tech_pvt->from_str)) {
+			rpid_domain = switch_core_session_strdup(session, tech_pvt->from_str);
+		} 
+
 		sofia_glue_get_url_from_contact(rpid_domain, 0);
 		if ((rpid_domain = strrchr(rpid_domain, '@'))) {
 			rpid_domain++;