notes: 加重命名 — title 旁边 ✏️ 按钮 prompt 改名 (PATCH /api/recordings/:id)
deploy notes / build-and-deploy (push) Successful in 1m53s

This commit is contained in:
Fam Zheng
2026-05-17 23:28:57 +01:00
parent 674011ddf3
commit 34fa47f95f
3 changed files with 48 additions and 2 deletions
+26 -1
View File
@@ -103,7 +103,7 @@ async fn main() -> std::io::Result<()> {
.route("/recordings", get(list_recordings).post(upload_recording).layer(
DefaultBodyLimit::max(REQUEST_BYTES),
))
.route("/recordings/:id", get(get_recording).delete(delete_recording))
.route("/recordings/:id", get(get_recording).patch(patch_recording).delete(delete_recording))
.route("/recordings/:id/audio", get(stream_audio))
.route("/recordings/:id/retry", post(retry_recording))
.route("/recordings/:id/feishu", post(convert_feishu))
@@ -580,6 +580,31 @@ async fn call_llm_summary(s: &AppState, transcript: &str) -> Result<String, Stri
Ok(text)
}
#[derive(serde::Deserialize)]
struct PatchRecording {
title: Option<String>,
}
async fn patch_recording(
State(s): State<AppState>,
Path(id): Path<i64>,
JsonResp(body): JsonResp<PatchRecording>,
) -> Result<JsonResp<Value>, AppError> {
let conn = s.db.lock().unwrap();
let exists: bool = conn
.query_row("SELECT 1 FROM recordings WHERE id = ?1", params![id], |_| Ok(true))
.optional()?
.unwrap_or(false);
if !exists { return Err(AppError::NotFound); }
if let Some(t) = body.title.as_ref() {
let t = t.trim();
if t.is_empty() { return Err(AppError::bad_request("title can't be blank")); }
let t: String = t.chars().take(120).collect();
conn.execute("UPDATE recordings SET title = ?1 WHERE id = ?2", params![&t, id])?;
}
Ok(JsonResp(json!({ "ok": true })))
}
async fn delete_recording(
State(s): State<AppState>,
Path(id): Path<i64>,