fix provider pool quota status handling

This commit is contained in:
fawney19
2026-05-07 11:28:44 +08:00
parent 01c9f9be49
commit fd44906bb7
37 changed files with 1844 additions and 500 deletions
+27 -6
View File
@@ -395,17 +395,38 @@ pub fn admin_pool_is_oauth_invalid(key: &StoredProviderCatalogKey, now_unix_secs
if key.auth_type.trim() != "oauth" {
return false;
}
if key
.oauth_invalid_reason
.as_deref()
.is_some_and(|value| !value.trim().is_empty())
{
return true;
if let Some(reason) = key.oauth_invalid_reason.as_deref().map(str::trim) {
let account_state = provider_status::resolve_pool_account_state(
None,
key.upstream_metadata.as_ref(),
Some(reason),
);
if account_state.blocked && !account_state.recoverable {
return true;
}
if admin_pool_reason_has_tag(reason, "[REFRESH_FAILED]") {
return key
.expires_at_unix_secs
.is_none_or(|value| value == 0 || value <= now_unix_secs);
}
if admin_pool_reason_has_tag(reason, "[REQUEST_FAILED]") {
return false;
}
if !reason.is_empty() {
return true;
}
}
key.expires_at_unix_secs
.is_some_and(|value| value > 0 && value <= now_unix_secs)
}
fn admin_pool_reason_has_tag(reason: &str, tag: &str) -> bool {
reason
.lines()
.map(str::trim)
.any(|line| line.starts_with(tag))
}
pub fn admin_pool_matches_quick_selector(
key: &StoredProviderCatalogKey,
selector: &str,