aboutsummaryrefslogtreecommitdiffstats
path: root/src/api.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api.rs')
-rw-r--r--src/api.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/api.rs b/src/api.rs
index 41ed7be..03b9c6d 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -148,6 +148,16 @@ struct SyncResProfile {
key: String,
#[serde(rename = "PrivateKey")]
private_key: String,
+ #[serde(rename = "Organizations")]
+ organizations: Vec<SyncResProfileOrganization>,
+}
+
+#[derive(serde::Deserialize, Debug)]
+struct SyncResProfileOrganization {
+ #[serde(rename = "Id")]
+ id: String,
+ #[serde(rename = "Key")]
+ key: String,
}
#[derive(serde::Deserialize, Debug, Clone)]
@@ -321,7 +331,12 @@ impl Client {
pub async fn sync(
&self,
access_token: &str,
- ) -> Result<(String, String, Vec<crate::db::Entry>)> {
+ ) -> Result<(
+ String,
+ String,
+ std::collections::HashMap<String, String>,
+ Vec<crate::db::Entry>,
+ )> {
let client = reqwest::Client::new();
let res = client
.get(&self.api_url("/sync"))
@@ -339,9 +354,16 @@ impl Client {
.iter()
.filter_map(|cipher| cipher.to_entry(&folders))
.collect();
+ let org_keys = sync_res
+ .profile
+ .organizations
+ .iter()
+ .map(|org| (org.id.clone(), org.key.clone()))
+ .collect();
Ok((
sync_res.profile.key,
sync_res.profile.private_key,
+ org_keys,
ciphers,
))
}