Skip to content

Commit 4221533

Browse files
committed
fix: routed_callee preserves AOR, broadcast_event carries call_id, session_hook_ctx merge
1 parent 0f8fb36 commit 4221533

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

src/addons/cc

Submodule cc updated from 9a47561 to 1e692c1

src/proxy/proxy_call/sip_session.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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!(

src/rwi/gateway.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,15 +532,15 @@ impl RwiGateway {
532532
}
533533

534534
/// Send an event to every known session (broadcast).
535-
/// Note: Broadcasting does not cache events as there's no specific call_id.
535+
/// Call-scoped events (with `call_id`) carry it in the envelope so webhook
536+
/// consumers can correlate. Truly global events (agent_state_changed, etc.)
537+
/// have `call_id = None` and the envelope field is empty.
536538
pub fn broadcast_event(&self, event: &RwiEvent) {
537-
// Forward to webhook handler (if configured).
538-
// Use an empty call_id and zero sequence since broadcast events are not cached.
539539
if let Some(tx) = &self.webhook_tx {
540540
let entry = EventCacheEntry {
541541
sequence: 0,
542542
cached_at: chrono::Utc::now(),
543-
call_id: String::new(),
543+
call_id: event.call_id.clone().unwrap_or_default(),
544544
event: event.clone(),
545545
};
546546
let _ = tx.send(entry);

0 commit comments

Comments
 (0)