feat(oauth): 允许替换已失效的活跃 OAuth 账号并同步 status_snapshot

- 活跃但 token 已过期或刷新失败的重复账号视为可替换
- 清除失效标记、刷新配额时同步更新 status_snapshot.oauth
- oauth_invalid 清除接口同时识别 invalid_at 与 invalid_reason 两种标记
- 批量导入任务状态区分 created_count / replaced_count,前端据此展示新增/替换统计
- 补充重复替换场景的集成测试,用量测试等待超时从 10s 提升到 30s 以适应并行压力
This commit is contained in:
fawney19
2026-04-20 22:59:02 +08:00
parent cf7d129595
commit c5c56ff92f
15 changed files with 965 additions and 44 deletions
@@ -39,7 +39,13 @@ pub(super) async fn maybe_handle(
else {
return Ok(Some(not_found_response(format!("Key {key_id} 不存在"))));
};
if key.oauth_invalid_at_unix_secs.is_none() {
let has_invalid_marker = key.oauth_invalid_at_unix_secs.is_some()
|| key
.oauth_invalid_reason
.as_deref()
.map(str::trim)
.is_some_and(|value| !value.is_empty());
if !has_invalid_marker {
return Ok(Some(
Json(json!({
"message": "该 Key 当前无失效标记,无需清除"