From b413345ac1ae37d9d0a2bfcd51f57b94278598f5 Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Mon, 18 Sep 2023 18:21:25 +1000 Subject: [PATCH] fix mtxchat.client_sync() url query contruction --- apps/mtxchat/src/web.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/apps/mtxchat/src/web.rs b/apps/mtxchat/src/web.rs index 405f8cf0f..c351dae34 100644 --- a/apps/mtxchat/src/web.rs +++ b/apps/mtxchat/src/web.rs @@ -330,7 +330,6 @@ pub fn get_filter( token: &str, agent: &mut Agent, ) -> Option { - let mut path = String::from("_matrix/client/v3/user/"); path.push_str(&user); path.push_str("/filter"); @@ -407,16 +406,11 @@ pub fn client_sync( ) -> Option<(String, Vec)> { log::info!("heap usage: {}", crate::heap_usage()); url.set_path("_matrix/client/r0/sync"); - let mut filter_q = String::from("filter="); - filter_q.push_str(&filter); - url.set_query(Some(&filter_q)); - let mut timeout_q = String::from("timeout="); - url.set_query(Some(&timeout_q)); - timeout_q.push_str(&timeout.to_string()); - let mut since_q = String::from("since="); + url.query_pairs_mut().append_pair("filter", &filter); + url.query_pairs_mut() + .append_pair("timeout", &timeout.to_string()); if let Some(since) = since { - since_q.push_str(since); - url.set_query(Some(&since_q)); + url.query_pairs_mut().append_pair("since", since); } log::info!("client_sync = {}", url.as_str()); if let Some(value) = handle_response(get_json_auth(&url, token, agent)) {