mirror of
https://github.com/coral/sipcord-bridge.git
synced 2026-06-29 09:23:14 -06:00
slopfixing
This commit is contained in:
parent
b18b876cb3
commit
efb07ace5d
|
|
@ -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
|
||||
);
|
||||
|
||||
// Ring ALL registered contacts simultaneously
|
||||
for (contact_uri, source_addr, transport) in &contacts {
|
||||
if req.sip_uri.is_some() {
|
||||
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: contact_uri.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 {
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue