From c8b45f5fe5284965a25894d1c7d9427988883b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 20 Feb 2018 14:09:00 +0100 Subject: [PATCH] Added equivalent domains to /api/sync --- src/api/core/ciphers.rs | 18 ++++++++---------- src/api/core/mod.rs | 5 +++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs index d66b444..c43cb34 100644 --- a/src/api/core/ciphers.rs +++ b/src/api/core/ciphers.rs @@ -16,30 +16,28 @@ use db::models::*; use util; use crypto; -use api::{JsonResult, EmptyResult}; +use api::{self, JsonResult, EmptyResult}; use auth::Headers; use CONFIG; #[get("/sync")] fn sync(headers: Headers, conn: DbConn) -> JsonResult { - let user = &headers.user; + let user_json = headers.user.to_json(); - let folders = Folder::find_by_user(&user.uuid, &conn); + let folders = Folder::find_by_user(&headers.user.uuid, &conn); let folders_json: Vec = folders.iter().map(|c| c.to_json()).collect(); - let ciphers = Cipher::find_by_user(&user.uuid, &conn); + let ciphers = Cipher::find_by_user(&headers.user.uuid, &conn); let ciphers_json: Vec = ciphers.iter().map(|c| c.to_json(&headers.host, &conn)).collect(); + let domains_json = api::core::get_eq_domains(headers).unwrap().into_inner(); + Ok(Json(json!({ - "Profile": user.to_json(), + "Profile": user_json, "Folders": folders_json, "Ciphers": ciphers_json, - "Domains": { - "EquivalentDomains": [], - "GlobalEquivalentDomains": [], - "Object": "domains", - }, + "Domains": domains_json, "Object": "sync" }))) } diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs index 17118f6..033bab3 100644 --- a/src/api/core/mod.rs +++ b/src/api/core/mod.rs @@ -103,7 +103,7 @@ struct GlobalDomain { const GLOBAL_DOMAINS: &'static str = include_str!("global_domains.json"); #[get("/settings/domains")] -fn get_eq_domains(headers: Headers, conn: DbConn) -> JsonResult { +fn get_eq_domains(headers: Headers) -> JsonResult { let user = headers.user; use serde_json::from_str; @@ -118,7 +118,8 @@ fn get_eq_domains(headers: Headers, conn: DbConn) -> JsonResult { Ok(Json(json!({ "EquivalentDomains": equivalent_domains, - "GlobalEquivalentDomains": globals + "GlobalEquivalentDomains": globals, + "Object": "domains", }))) }