fix: pre-release audit fixes — Twitter OAuth, DataMasking perf, Prompt versioning

- Twitter like/retweet: return explicit unavailable error instead of
  sending doomed Bearer token requests (would 403 on Twitter API v2)
- DataMasking: pre-compile regex patterns with LazyLock (was compiling
  6 patterns on every mask() call)
- Prompt version: fix get_version handler ignoring version path param,
  add service::get_version_by_number for correct per-version retrieval
This commit is contained in:
iven
2026-04-09 16:43:24 +08:00
parent f2d6a3b6b7
commit 3f2acb49fb
4 changed files with 99 additions and 79 deletions

View File

@@ -122,12 +122,11 @@ pub async fn list_versions(
pub async fn get_version(
State(state): State<AppState>,
Extension(ctx): Extension<AuthContext>,
Path((name, _version)): Path<(String, i32)>,
Path((name, version)): Path<(String, i32)>,
) -> SaasResult<Json<PromptVersionInfo>> {
check_permission(&ctx, "prompt:read")?;
let _tmpl = service::get_template_by_name(&state.db, &name).await?;
Ok(Json(service::get_current_version(&state.db, &name).await?))
Ok(Json(service::get_version_by_number(&state.db, &name, version).await?))
}
/// POST /api/v1/prompts/{name}/versions — 发布新版本