Selaa lähdekoodia

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

Fixed duplication at the end of url origin
develop
Predko Silvestr 2 vuotta sitten
vanhempi
commit
38e3a72b2d
No account linked to committer's email address
1 muutettua tiedostoa jossa 16 lisäystä ja 13 poistoa
  1. 16
    13
      web-client/src/lib.rs

+ 16
- 13
web-client/src/lib.rs Näytä tiedosto

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

Loading…
Peruuta
Tallenna