瀏覽代碼

Merge pull request #51 from Relayz-io/silvestr/fix-url-slash-duplication

Fixed duplication at the end of url origin
develop
Predko Silvestr 2 年之前
父節點
當前提交
38e3a72b2d
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 16 行新增13 行删除
  1. 16
    13
      web-client/src/lib.rs

+ 16
- 13
web-client/src/lib.rs 查看文件

@@ -140,7 +140,7 @@ impl KeyProvisioner {
140 140
         wasm_bindgen_futures::future_to_promise(async move {
141 141
             let exchange_uuid = uuid::Uuid::new_v4();
142 142
             let (contract_id, owner_pk) =
143
-                { (handler.contract_id.clone(), Public::from(&handler.owner_sk)) };
143
+                (handler.contract_id.clone(), Public::from(&handler.owner_sk));
144 144
 
145 145
             let res: Vec<Result<String>> = participants_set
146 146
                 .keys()
@@ -195,7 +195,7 @@ impl KeyProvisioner {
195 195
                 .as_ref()
196 196
                 .ok_or_else(|| ApiError::new(ErrorType::Other, "Empty participants".to_owned()))?;
197 197
 
198
-            let (contract_id, url) = { (handler.contract_id.clone(), handler.url.to_string()) };
198
+            let (contract_id, url) = (handler.contract_id.clone(), &handler.url);
199 199
 
200 200
             let participants_keys =
201 201
                 futures::future::try_join_all(participants.iter().map(|participant| {
@@ -251,11 +251,15 @@ impl KeyProvisioner {
251 251
                 })
252 252
                 .try_collect()?;
253 253
 
254
+            let meeting_url = url
255
+                .join("meeting")
256
+                .map_err(|err| ApiError::new(ErrorType::Other, err.to_string()))?;
257
+
254 258
             let _: Vec<reqwest::Response> = futures::future::try_join_all(
255 259
                 encrypted_keys.into_iter().map(|(bytes, participant_id)| {
256 260
                     let client = reqwest::ClientBuilder::new().build().unwrap();
257 261
                     client
258
-                        .post(format!("{url}/meeting"))
262
+                        .post(meeting_url.clone())
259 263
                         .query(&[
260 264
                             ("id", serde_json::to_value(meeting_id.clone()).unwrap()),
261 265
                             ("participant", serde_json::to_value(participant_id).unwrap()),
@@ -284,17 +288,17 @@ impl KeyProvisioner {
284 288
 
285 289
         wasm_bindgen_futures::future_to_promise(async move {
286 290
             let signer = signer.lock().await;
287
-            let (contract_id, sk, url) = {
288
-                (
289
-                    handler.contract_id.clone(),
290
-                    &handler.owner_sk,
291
-                    handler.url.to_string(),
292
-                )
293
-            };
291
+            let (contract_id, sk, url) =
292
+                (handler.contract_id.clone(), &handler.owner_sk, &handler.url);
293
+
294
+            let meeting_url = url
295
+                .join("meeting")
296
+                .map_err(|err| ApiError::new(ErrorType::Other, err.to_string()))?;
297
+
294 298
             loop {
295 299
                 let http_client = reqwest::ClientBuilder::new().build().unwrap();
296 300
                 let msg = http_client
297
-                    .get(format!("{}/meeting", &url))
301
+                    .get(meeting_url.clone())
298 302
                     .query(&[
299 303
                         ("id", serde_json::to_value(meeting_id.clone()).unwrap()),
300 304
                         (
@@ -350,8 +354,7 @@ impl KeyProvisioner {
350 354
         let client = self.client();
351 355
         let signer = self.signer();
352 356
         wasm_bindgen_futures::future_to_promise(async move {
353
-            let (contract_id, pk) =
354
-                { (handler.contract_id.clone(), Public::from(&handler.owner_sk)) };
357
+            let (contract_id, pk) = (handler.contract_id.clone(), Public::from(&handler.owner_sk));
355 358
             client
356 359
                 .function_call(signer.lock().await.deref_mut(), &contract_id, "set_key")
357 360
                 .gas(near_units::parse_gas!("300 T") as u64)

Loading…
取消
儲存