Add back document ids
This commit is contained in:
parent
cd46acd130
commit
c567cec656
1 changed files with 277 additions and 100 deletions
|
|
@ -13,7 +13,7 @@ use serde::Deserialize;
|
|||
use super::auth::auth;
|
||||
use crate::{
|
||||
app_state::AppState,
|
||||
database::models::{DocumentVersion, VaultId},
|
||||
database::models::{DocumentId, DocumentVersion, VaultId},
|
||||
errors::{not_found_error, server_error, SyncServerError},
|
||||
};
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ use crate::{
|
|||
#[derive(Deserialize, JsonSchema)]
|
||||
pub struct PathParams {
|
||||
vault_id: VaultId,
|
||||
relative_path: String,
|
||||
document_id: DocumentId,
|
||||
}
|
||||
|
||||
#[axum::debug_handler]
|
||||
|
|
@ -29,7 +29,7 @@ pub async fn fetch_latest_document_version(
|
|||
TypedHeader(auth_header): TypedHeader<Authorization<Bearer>>,
|
||||
Path(PathParams {
|
||||
vault_id,
|
||||
relative_path,
|
||||
document_id,
|
||||
}): Path<PathParams>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<DocumentVersion>, SyncServerError> {
|
||||
|
|
@ -37,14 +37,13 @@ pub async fn fetch_latest_document_version(
|
|||
|
||||
let latest_version = state
|
||||
.database
|
||||
.get_latest_document(&vault_id, &relative_path, None)
|
||||
.get_latest_document(&vault_id, &document_id, None)
|
||||
.await
|
||||
.map_err(server_error)?
|
||||
.map(Ok)
|
||||
.unwrap_or_else(|| {
|
||||
Err(not_found_error(anyhow!(
|
||||
"Latest document version of document `{}` not found",
|
||||
relative_path
|
||||
"Document with id `{document_id}` not found",
|
||||
)))
|
||||
})?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue