Add api version check to client

This commit is contained in:
Andras Schmelczer 2025-11-23 22:12:49 +00:00
parent b1826907e7
commit 3ed2e4f666
10 changed files with 52 additions and 3 deletions

View file

@ -16,3 +16,5 @@ pub const DEFAULT_LOG_DIRECTORY: &str = "logs";
pub const DEFAULT_LOG_ROTATION_INTERVAL: Duration = Duration::from_secs(60 * 60 * 24); // 1 day
pub const DEFAULT_MERGEABLE_FILE_EXTENSIONS: &[&str] = &["md", "txt"];
pub const SUPPORTED_API_VERSION: u32 = 1;

View file

@ -11,6 +11,7 @@ use serde::Deserialize;
use super::{auth::auth, responses::PingResponse};
use crate::{
app_state::{AppState, database::models::VaultId},
consts::SUPPORTED_API_VERSION,
errors::SyncServerError,
utils::normalize::normalize,
};
@ -34,5 +35,6 @@ pub async fn ping(
server_version: env!("CARGO_PKG_VERSION").to_owned(),
is_authenticated,
mergeable_file_extensions: state.config.server.mergeable_file_extensions.clone(),
supported_api_version: SUPPORTED_API_VERSION,
}))
}

View file

@ -19,6 +19,10 @@ pub struct PingResponse {
/// List of file extensions that are allowed to be merged.
pub mergeable_file_extensions: Vec<String>,
/// API version ensuring backwards & forwards compatibility between the client
/// and server.
pub supported_api_version: u32,
}
/// Response to a fetch latest documents request.