fix: update sync behavior to set domains to null when excludeDomains is true and add culture to profile
This commit is contained in:
parent
ef98bcc5a5
commit
975f470ddf
2 changed files with 9 additions and 5 deletions
|
|
@ -23,7 +23,7 @@ use serde_json::{json, Value};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct SyncQuery {
|
pub struct SyncQuery {
|
||||||
/// If true, omit domains data from sync (vaultwarden sets domains to null).
|
/// If true, set `domains` to null (vaultwarden behavior).
|
||||||
#[serde(rename = "excludeDomains", default)]
|
#[serde(rename = "excludeDomains", default)]
|
||||||
pub exclude_domains: bool,
|
pub exclude_domains: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,7 @@ pub async fn get_sync_data(
|
||||||
// "collections": [],
|
// "collections": [],
|
||||||
// "policies": [],
|
// "policies": [],
|
||||||
// "ciphers": [...],
|
// "ciphers": [...],
|
||||||
// "domains": {...}, // omitted when excludeDomains=true
|
// "domains": {...} | null, // null when excludeDomains=true
|
||||||
// "sends": [],
|
// "sends": [],
|
||||||
// "userDecryption": {...},
|
// "userDecryption": {...},
|
||||||
// "object": "sync"
|
// "object": "sync"
|
||||||
|
|
@ -135,13 +135,16 @@ pub async fn get_sync_data(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if !query.exclude_domains {
|
response.push_str(",\"domains\":");
|
||||||
|
if query.exclude_domains {
|
||||||
|
response.push_str("null");
|
||||||
|
} else {
|
||||||
// Match vaultwarden sync semantics:
|
// Match vaultwarden sync semantics:
|
||||||
// - mark excluded in /api/settings/domains
|
// - mark excluded in /api/settings/domains
|
||||||
// - filter excluded out of sync payload
|
// - filter excluded out of sync payload
|
||||||
let global_equivalent_domains =
|
let global_equivalent_domains =
|
||||||
domains::global_equivalent_domains_json(&db, &excluded_globals, false).await;
|
domains::global_equivalent_domains_json(&db, &excluded_globals, false).await;
|
||||||
response.push_str(",\"domains\":{\"equivalentDomains\":");
|
response.push_str("{\"equivalentDomains\":");
|
||||||
response.push_str(&equivalent_domains);
|
response.push_str(&equivalent_domains);
|
||||||
response.push_str(",\"globalEquivalentDomains\":");
|
response.push_str(",\"globalEquivalentDomains\":");
|
||||||
response.push_str(&global_equivalent_domains);
|
response.push_str(&global_equivalent_domains);
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ use serde_json::Value;
|
||||||
pub struct Profile {
|
pub struct Profile {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub avatar_color: Option<String>,
|
pub avatar_color: Option<String>,
|
||||||
pub email: String,
|
pub email: String,
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub security_stamp: String,
|
pub security_stamp: String,
|
||||||
pub object: String,
|
pub object: String,
|
||||||
pub premium_from_organization: bool,
|
pub premium_from_organization: bool,
|
||||||
|
pub culture: String,
|
||||||
pub force_password_reset: bool,
|
pub force_password_reset: bool,
|
||||||
pub email_verified: bool,
|
pub email_verified: bool,
|
||||||
pub two_factor_enabled: bool,
|
pub two_factor_enabled: bool,
|
||||||
|
|
@ -48,6 +48,7 @@ impl Profile {
|
||||||
security_stamp: user.security_stamp,
|
security_stamp: user.security_stamp,
|
||||||
object: "profile".to_string(),
|
object: "profile".to_string(),
|
||||||
premium_from_organization: false,
|
premium_from_organization: false,
|
||||||
|
culture: "en-US".to_string(),
|
||||||
force_password_reset: false,
|
force_password_reset: false,
|
||||||
email_verified: true,
|
email_verified: true,
|
||||||
two_factor_enabled,
|
two_factor_enabled,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue