feat: Introduce note version history with dedicated UI, API, and database schema.

This commit is contained in:
2025-12-23 03:08:14 +01:00
parent 7aad3b7d84
commit c441f14bfa
12 changed files with 408 additions and 10 deletions

View File

@@ -177,3 +177,28 @@ pub async fn search_notes(
Ok(Json(response))
}
/// List versions of a note
/// GET /api/v1/notes/:id/versions
pub async fn list_note_versions(
State(state): State<AppState>,
auth: AuthSession<AuthBackend>,
Path(id): Path<Uuid>,
) -> ApiResult<Json<Vec<crate::dto::NoteVersionResponse>>> {
let user = auth
.user
.ok_or(ApiError::Domain(notes_domain::DomainError::Unauthorized(
"Login required".to_string(),
)))?;
let user_id = user.id();
let service = NoteService::new(state.note_repo, state.tag_repo);
let versions = service.list_note_versions(id, user_id).await?;
let response: Vec<crate::dto::NoteVersionResponse> = versions
.into_iter()
.map(crate::dto::NoteVersionResponse::from)
.collect();
Ok(Json(response))
}