api: add JSON-RPC API to get ICE servers

Currently with a hardcoded TURN server
so it can be used in the UIs.
This commit is contained in:
link2xt
2025-09-16 19:00:58 +00:00
parent 3d2805bc78
commit c5ada9b203
4 changed files with 68 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ use std::{collections::HashMap, str::FromStr};
use anyhow::{anyhow, bail, ensure, Context, Result};
pub use deltachat::accounts::Accounts;
use deltachat::blob::BlobObject;
use deltachat::calls::ice_servers;
use deltachat::chat::{
self, add_contact_to_chat, forward_msgs, get_chat_media, get_chat_msgs, get_chat_msgs_ex,
marknoticed_chat, remove_contact_from_chat, Chat, ChatId, ChatItem, MessageListOptions,
@@ -2111,6 +2112,12 @@ impl CommandApi {
Ok(())
}
/// Returns JSON with ICE servers, to be used for WebRTC video calls.
async fn ice_servers(&self, account_id: u32) -> Result<String> {
let ctx = self.get_context(account_id).await?;
ice_servers(&ctx).await
}
/// Makes an HTTP GET request and returns a response.
///
/// `url` is the HTTP or HTTPS URL.