@@ -2248,11 +2248,23 @@ impl SipSession {
22482248 }
22492249 }
22502250 }
2251+ let connected_callee = self
2252+ . meta
2253+ . routed_callee
2254+ . clone ( )
2255+ . or_else ( || self . meta . connected_callee . clone ( ) ) ;
2256+ info ! (
2257+ session_id = %self . context. session_id,
2258+ routed_callee = ?self . meta. routed_callee,
2259+ connected_callee = ?self . meta. connected_callee,
2260+ resolved = ?connected_callee,
2261+ "session_hook_ctx: connected_callee resolution"
2262+ ) ;
22512263 crate :: proxy:: proxy_call:: session_hooks:: CallSessionContext {
22522264 session_id : self . context . session_id . clone ( ) ,
22532265 caller : self . context . original_caller . clone ( ) ,
22542266 callee : self . context . original_callee . clone ( ) ,
2255- connected_callee : self . meta . connected_callee . clone ( ) ,
2267+ connected_callee,
22562268 queue_name : self . meta . queue_name . clone ( ) ,
22572269 direction : self . context . dialplan . direction . to_string ( ) ,
22582270 started_at : Some ( self . context . created_at . clone ( ) ) ,
@@ -3682,7 +3694,12 @@ impl SipSession {
36823694 . caller
36833695 . as_ref ( )
36843696 . map ( |uri| uri. to_string ( ) ) ;
3685- self . meta . routed_callee = Some ( callee_uri. to_string ( ) ) ;
3697+ // Store original target AOR, not resolved contact.
3698+ let winner_aor = targets
3699+ . get ( winner_idx)
3700+ . map ( |t| t. aor . to_string ( ) )
3701+ . unwrap_or_else ( || callee_uri. to_string ( ) ) ;
3702+ self . meta . routed_callee = Some ( winner_aor) ;
36863703
36873704 // Cancel all remaining forks
36883705 fork_cancel. cancel ( ) ;
@@ -4500,7 +4517,10 @@ impl SipSession {
45004517 self . build_target_invite_option ( target, None ) . await ?;
45014518
45024519 self . meta . routed_caller = Some ( invite_option. caller . to_string ( ) ) ;
4503- self . meta . routed_callee = Some ( invite_option. callee . to_string ( ) ) ;
4520+ // Store the original target AOR (e.g. "sip:test001@localhost"), NOT
4521+ // the resolved contact URI (e.g. WebRTC contact "sip:abc123@...;transport=WS").
4522+ // This is used by session hooks to resolve agent identity.
4523+ self . meta . routed_callee = Some ( target. aor . to_string ( ) ) ;
45044524
45054525 if let Some ( home_proxy) = target. home_proxy . as_ref ( ) {
45064526 info ! (
0 commit comments