aboutsummaryrefslogtreecommitdiffstats
path: root/src/api.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-05-03 02:38:01 -0400
committerJesse Luehrs <doy@tozt.net>2020-05-03 02:38:01 -0400
commit1b0b0e9eaa546f50f6916cc631edaaa7dc8442e8 (patch)
treeb464713fdc59bbdb9006842a03de9cbddbd1dddf /src/api.rs
parente89ecaf0792dea1d36b6f071cb32bf79665c8e37 (diff)
downloadrbw-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.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,
))
}