From efb07ace5dca3606469c84364685d5b755477a1e Mon Sep 17 00:00:00 2001 From: legop3 Date: Sun, 14 Jun 2026 00:10:35 -0400 Subject: [PATCH] slopfixing --- sipcord-bridge/src/call/mod.rs | 33 +++++++++------------ sipcord-bridge/src/transport/discord/mod.rs | 8 ++--- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/sipcord-bridge/src/call/mod.rs b/sipcord-bridge/src/call/mod.rs index 1194ef8..2de3f72 100644 --- a/sipcord-bridge/src/call/mod.rs +++ b/sipcord-bridge/src/call/mod.rs @@ -524,19 +524,13 @@ impl BridgeCoordinator { // Either dial the explicitly configured SIP URI, or look up // registered contacts for the Discord username. - let contacts = if let Some(sip_uri) = req.sip_uri.clone() { - vec![( - sip_uri, - String::new(), - crate::services::registrar::SipTransport::Udp, - )] - } else if let Some(ref registrar) = outbound_registrar { + let contacts = if let Some(ref registrar) = outbound_registrar { registrar.get_contacts_for_discord_user(&req.discord_username) } else { Vec::new() }; - if contacts.is_empty() { + if req.sip_uri.is_none() && contacts.is_empty() { warn!( "No SIP contacts for user {} (call_id={})", req.discord_username, req.call_id @@ -548,24 +542,25 @@ impl BridgeCoordinator { // Store the request so handle_outbound_call_answered can retrieve it outbound_requests_for_handler.insert(req.call_id.clone(), req.clone()); - let fork_total = contacts.len(); + let fork_total = if req.sip_uri.is_some() { 1 } else { contacts.len() }; info!( "Forking outbound call to {} contacts for user {} (call_id={})", fork_total, req.discord_username, req.call_id ); + if let Some(sip_uri) = req.sip_uri.clone() { + let _ = outbound_sip_cmd_tx.send(SipCommand::MakeOutboundCall { + tracking_id: req.call_id.clone(), + sip_uri, + caller_display_name: Some(req.caller_username.clone()), + fork_total, + }); + outbound_backend.report_call_status(&req.call_id, "ringing"); + continue; + } + // Ring ALL registered contacts simultaneously for (contact_uri, source_addr, transport) in &contacts { - if req.sip_uri.is_some() { - let _ = outbound_sip_cmd_tx.send(SipCommand::MakeOutboundCall { - tracking_id: req.call_id.clone(), - sip_uri: contact_uri.clone(), - caller_display_name: Some(req.caller_username.clone()), - fork_total, - }); - continue; - } - // Extract the user part from the Contact URI (e.g., "sip:3001@10.0.1.151:5060" -> "3001") // The contact_uri has the correct SIP username/extension; source_addr is the NAT'd public address let user_part = contact_uri diff --git a/sipcord-bridge/src/transport/discord/mod.rs b/sipcord-bridge/src/transport/discord/mod.rs index 4973256..1017eac 100644 --- a/sipcord-bridge/src/transport/discord/mod.rs +++ b/sipcord-bridge/src/transport/discord/mod.rs @@ -614,7 +614,7 @@ impl EventHandler for SharedClientEventHandler { } } } - FullEvent::InteractionCreate { interaction } => { + FullEvent::InteractionCreate { interaction, .. } => { if let Some(ref cfg) = self.outbound_call_config && let Interaction::Command(command) = interaction && command.data.name == "call" @@ -639,7 +639,7 @@ async fn register_call_command(ctx: &Context, guild_id: GuildId) -> Result<(), s .required(true), ); - Command::create_guild_command(&ctx.http, guild_id, command).await?; + guild_id.create_command(&ctx.http, command).await?; info!("Registered /call command for guild {}", guild_id); Ok(()) } @@ -662,7 +662,7 @@ async fn handle_call_command( if let Err(e) = command .create_response( - ctx, + &ctx.http, CreateInteractionResponse::Message( CreateInteractionResponseMessage::new() .content(response) @@ -723,7 +723,7 @@ fn build_outbound_request( guild_id: guild_id.get().to_string(), channel_id: voice_channel_id.get().to_string(), bot_token: cfg.bot_token.clone(), - caller_username, + caller_username: caller_username.to_string(), sip_uri: Some(cfg.sip.build_sip_uri(&extension)), created_at: std::time::Instant::now(), })