From 1b0b0e9eaa546f50f6916cc631edaaa7dc8442e8 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 3 May 2020 02:38:01 -0400 Subject: also store org keys in the local db --- src/api.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/api.rs') 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, +} + +#[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)> { + ) -> Result<( + String, + String, + std::collections::HashMap, + Vec, + )> { 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, )) } -- cgit v1.2.3-54-g00ecf