Skip to content

Commit 9e173d8

Browse files
committed
fix: session_hook_ctx merges routing metadata instead of overwriting addon data
1 parent 4c310ff commit 9e173d8

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/addons/cc

Submodule cc updated from 4f0d548 to 3cf29b5

src/proxy/proxy_call/sip_session.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,10 +2231,21 @@ impl SipSession {
22312231
}
22322232

22332233
fn session_hook_ctx(&self) -> crate::proxy::proxy_call::session_hooks::CallSessionContext {
2234-
// Pre-populate routing metadata (X-CRM-* / X-CC-*) into extensions.
2234+
// Merge routing metadata (X-CRM-* / X-CC-*) into extensions.
2235+
// Use entry() to avoid overwriting keys already set by addons (e.g.
2236+
// CcCallSessionHook writes agent_id/agent_name here).
22352237
if let Some(ref m) = self.context.metadata {
22362238
if !m.is_empty() {
2237-
self.extensions.write().insert(m.clone());
2239+
let mut ext = self.extensions.write();
2240+
if let Some(existing) =
2241+
ext.get_mut::<std::collections::HashMap<String, String>>()
2242+
{
2243+
for (k, v) in m {
2244+
existing.entry(k.clone()).or_insert(v.clone());
2245+
}
2246+
} else {
2247+
ext.insert(m.clone());
2248+
}
22382249
}
22392250
}
22402251
crate::proxy::proxy_call::session_hooks::CallSessionContext {

0 commit comments

Comments
 (0)