diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-05-03 02:38:01 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-05-03 02:38:01 -0400 |
commit | 1b0b0e9eaa546f50f6916cc631edaaa7dc8442e8 (patch) | |
tree | b464713fdc59bbdb9006842a03de9cbddbd1dddf /src/api.rs | |
parent | e89ecaf0792dea1d36b6f071cb32bf79665c8e37 (diff) | |
download | rbw-1b0b0e9eaa546f50f6916cc631edaaa7dc8442e8.tar.gz rbw-1b0b0e9eaa546f50f6916cc631edaaa7dc8442e8.zip |
also store org keys in the local db
Diffstat (limited to 'src/api.rs')
-rw-r--r-- | src/api.rs | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -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, )) } |