fix: update sync behavior to set domains to null when excludeDomains is true and add culture to profile

This commit is contained in:
qaz741wsd856 2026-01-25 11:49:53 +00:00
parent ef98bcc5a5
commit 975f470ddf
2 changed files with 9 additions and 5 deletions

View file

@ -23,7 +23,7 @@ use serde_json::{json, Value};
#[derive(Debug, Deserialize)]
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)]
pub exclude_domains: bool,
}
@ -111,7 +111,7 @@ pub async fn get_sync_data(
// "collections": [],
// "policies": [],
// "ciphers": [...],
// "domains": {...}, // omitted when excludeDomains=true
// "domains": {...} | null, // null when excludeDomains=true
// "sends": [],
// "userDecryption": {...},
// "object": "sync"
@ -135,13 +135,16 @@ pub async fn get_sync_data(
)
.await?;
if !query.exclude_domains {
response.push_str(",\"domains\":");
if query.exclude_domains {
response.push_str("null");
} else {
// Match vaultwarden sync semantics:
// - mark excluded in /api/settings/domains
// - filter excluded out of sync payload
let global_equivalent_domains =
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(",\"globalEquivalentDomains\":");
response.push_str(&global_equivalent_domains);

View file

@ -9,13 +9,13 @@ use serde_json::Value;
pub struct Profile {
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_color: Option<String>,
pub email: String,
pub id: String,
pub security_stamp: String,
pub object: String,
pub premium_from_organization: bool,
pub culture: String,
pub force_password_reset: bool,
pub email_verified: bool,
pub two_factor_enabled: bool,
@ -48,6 +48,7 @@ impl Profile {
security_stamp: user.security_stamp,
object: "profile".to_string(),
premium_from_organization: false,
culture: "en-US".to_string(),
force_password_reset: false,
email_verified: true,
two_factor_enabled,