mirror of
https://github.com/coral/sipcord-bridge.git
synced 2026-06-29 17:32:52 -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
|
// Either dial the explicitly configured SIP URI, or look up
|
||||||
// registered contacts for the Discord username.
|
// registered contacts for the Discord username.
|
||||||
let contacts = if let Some(sip_uri) = req.sip_uri.clone() {
|
let contacts = if let Some(ref registrar) = outbound_registrar {
|
||||||
vec![(
|
|
||||||
sip_uri,
|
|
||||||
String::new(),
|
|
||||||
crate::services::registrar::SipTransport::Udp,
|
|
||||||
)]
|
|
||||||
} else if let Some(ref registrar) = outbound_registrar {
|
|
||||||
registrar.get_contacts_for_discord_user(&req.discord_username)
|
registrar.get_contacts_for_discord_user(&req.discord_username)
|
||||||
} else {
|
} else {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
if contacts.is_empty() {
|
if req.sip_uri.is_none() && contacts.is_empty() {
|
||||||
warn!(
|
warn!(
|
||||||
"No SIP contacts for user {} (call_id={})",
|
"No SIP contacts for user {} (call_id={})",
|
||||||
req.discord_username, req.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
|
// Store the request so handle_outbound_call_answered can retrieve it
|
||||||
outbound_requests_for_handler.insert(req.call_id.clone(), req.clone());
|
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!(
|
info!(
|
||||||
"Forking outbound call to {} contacts for user {} (call_id={})",
|
"Forking outbound call to {} contacts for user {} (call_id={})",
|
||||||
fork_total, req.discord_username, req.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
|
// Ring ALL registered contacts simultaneously
|
||||||
for (contact_uri, source_addr, transport) in &contacts {
|
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")
|
// 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
|
// The contact_uri has the correct SIP username/extension; source_addr is the NAT'd public address
|
||||||
let user_part = contact_uri
|
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
|
if let Some(ref cfg) = self.outbound_call_config
|
||||||
&& let Interaction::Command(command) = interaction
|
&& let Interaction::Command(command) = interaction
|
||||||
&& command.data.name == "call"
|
&& command.data.name == "call"
|
||||||
|
|
@ -639,7 +639,7 @@ async fn register_call_command(ctx: &Context, guild_id: GuildId) -> Result<(), s
|
||||||
.required(true),
|
.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);
|
info!("Registered /call command for guild {}", guild_id);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -662,7 +662,7 @@ async fn handle_call_command(
|
||||||
|
|
||||||
if let Err(e) = command
|
if let Err(e) = command
|
||||||
.create_response(
|
.create_response(
|
||||||
ctx,
|
&ctx.http,
|
||||||
CreateInteractionResponse::Message(
|
CreateInteractionResponse::Message(
|
||||||
CreateInteractionResponseMessage::new()
|
CreateInteractionResponseMessage::new()
|
||||||
.content(response)
|
.content(response)
|
||||||
|
|
@ -723,7 +723,7 @@ fn build_outbound_request(
|
||||||
guild_id: guild_id.get().to_string(),
|
guild_id: guild_id.get().to_string(),
|
||||||
channel_id: voice_channel_id.get().to_string(),
|
channel_id: voice_channel_id.get().to_string(),
|
||||||
bot_token: cfg.bot_token.clone(),
|
bot_token: cfg.bot_token.clone(),
|
||||||
caller_username,
|
caller_username: caller_username.to_string(),
|
||||||
sip_uri: Some(cfg.sip.build_sip_uri(&extension)),
|
sip_uri: Some(cfg.sip.build_sip_uri(&extension)),
|
||||||
created_at: std::time::Instant::now(),
|
created_at: std::time::Instant::now(),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue