Browse Source

Expose add_participant API

develop
Silvestr Predko 2 years ago
parent
commit
3e053acb5c
1 changed files with 25 additions and 0 deletions
  1. 25
    0
      web-client/src/lib.rs

+ 25
- 0
web-client/src/lib.rs View File

@@ -183,6 +183,31 @@ impl KeyProvisioner {
183 183
         })
184 184
     }
185 185
 
186
+    /// Add a participant to the current session
187
+    ///
188
+    /// Arguments
189
+    ///
190
+    /// - meeting_id - The [`String`] that indicates ID of the meeting room
191
+    /// - participant - [`AccountId`] of a desired participant
192
+    ///
193
+    /// Returns
194
+    ///
195
+    /// Transaction ID
196
+    #[wasm_bindgen(js_name = addParticipant)]
197
+    pub fn add_participant(&self, meeting_id: String, participant: String) -> Promise {
198
+        let handler = self.handler();
199
+        let signer = self.signer();
200
+        wasm_bindgen_futures::future_to_promise(async move {
201
+            let account_id = AccountId::from_str(&participant)
202
+                .map_err(|err| ApiError::InvalidAccountId(err.to_string()))?;
203
+            let meeting_id = uuid::Uuid::from_str(&meeting_id)
204
+                .map_err(|err| ApiError::InvalidSessionUuid(err.to_string()))?;
205
+            let transaction_id = add_participant(&handler, &signer, meeting_id, account_id).await?;
206
+
207
+            Ok(to_value(&transaction_id.to_string()))
208
+        })
209
+    }
210
+
186 211
     /// Sends participants' keys to the keys exchange server
187 212
     ///
188 213
     /// Arguments

Loading…
Cancel
Save