Add path change to server

This commit is contained in:
Andras Schmelczer 2026-04-21 20:09:36 +01:00
parent 9183f30b5d
commit dca59a18dc
9 changed files with 225 additions and 29 deletions

View file

@ -77,6 +77,72 @@ pub struct DocumentVersion {
pub device_id: DeviceId,
}
/// Like [`DocumentVersionWithoutContent`] but without the `relative_path`.
/// Used only in create/update responses where the client already tracks
/// the path locally (the server is the source of truth for the
/// document identity, not its path).
#[derive(TS, Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentUpdateMetadata {
#[ts(type = "number")]
pub vault_update_id: VaultUpdateId,
pub document_id: DocumentId,
pub updated_date: DateTime<Utc>,
pub is_deleted: bool,
pub user_id: UserId,
pub device_id: DeviceId,
#[ts(type = "number")]
pub content_size: u64,
}
impl From<StoredDocumentVersion> for DocumentUpdateMetadata {
fn from(value: StoredDocumentVersion) -> Self {
Self {
vault_update_id: value.vault_update_id,
document_id: value.document_id,
updated_date: value.updated_date,
is_deleted: value.is_deleted,
user_id: value.user_id,
device_id: value.device_id,
content_size: value.content.len() as u64,
}
}
}
/// Like [`DocumentVersion`] but without the `relative_path`.
/// Used only in create/update responses when the server had to merge the
/// client's content with a newer remote version and therefore must echo
/// the merged content back.
#[derive(TS, Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentUpdateMergedContent {
#[ts(type = "number")]
pub vault_update_id: VaultUpdateId,
pub document_id: DocumentId,
pub updated_date: DateTime<Utc>,
pub content_base64: String,
pub is_deleted: bool,
pub user_id: UserId,
pub device_id: DeviceId,
}
impl From<StoredDocumentVersion> for DocumentUpdateMergedContent {
fn from(value: StoredDocumentVersion) -> Self {
Self {
vault_update_id: value.vault_update_id,
document_id: value.document_id,
updated_date: value.updated_date,
content_base64: STANDARD.encode(&value.content),
is_deleted: value.is_deleted,
user_id: value.user_id,
device_id: value.device_id,
}
}
}
/// Row struct for vault history queries (used by `sqlx::query_as!`)
#[derive(Debug)]
pub struct VaultHistoryRow {