From 7bfbcc955c7c4b4e3bd210317277c5a2e4c1967b Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 20 Oct 2022 21:18:56 +0200 Subject: [PATCH] Add env var to support connecting to test servers --- native/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/native/src/lib.rs b/native/src/lib.rs index 9201a7d..b14759a 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -4,7 +4,7 @@ mod db; use grammers_client::types::{Dialog, LoginToken}; -use grammers_client::{Client, Config}; +use grammers_client::{Client, Config, InitParams}; use grammers_session::{PackedChat, Session, UpdateState}; use jni::objects::{JObject, JString}; use jni::sys::{jboolean, jint, jlong, jstring}; @@ -40,6 +40,7 @@ const API_ID: i32 = { value }; const API_HASH: &str = env!("TALARIA_API_HASH"); +const SERVER_ADDR: &str = env!("TALARIA_SERVER_ADDR"); static RUNTIME: OnceCell = OnceCell::new(); static CLIENT: OnceCell = OnceCell::new(); @@ -114,7 +115,14 @@ async fn init_client() -> Result<()> { session, api_id: API_ID, api_hash: API_HASH.to_string(), - params: Default::default(), + params: InitParams { + server_addr: if SERVER_ADDR.is_empty() { + None + } else { + Some(SERVER_ADDR.parse().unwrap()) + }, + ..Default::default() + }, }) .await?;