fix: 维护模式使用500条临时限额而非完全跳过(防滥用)
This commit is contained in:
@@ -1073,17 +1073,22 @@ pub async fn get_user_quota(
|
||||
|
||||
let (used, is_paid_active, paid_expires_at) =
|
||||
db::get_user_quota(pool.get_ref(), user_id).await?;
|
||||
let limit: i64 = std::env::var("FREE_USER_DATA_LIMIT")
|
||||
.ok()
|
||||
.and_then(|v| v.parse().ok())
|
||||
.unwrap_or(20);
|
||||
|
||||
let (unlimited, active) = if is_maintenance {
|
||||
(true, true)
|
||||
// 维护模式使用更高的临时限额,但非会员仍然有限制防止滥用
|
||||
let (limit, unlimited) = if is_maintenance && !is_paid_active {
|
||||
let ml: i64 = std::env::var("MAINTENANCE_MODE_DATA_LIMIT")
|
||||
.ok().and_then(|v| v.parse().ok()).unwrap_or(500);
|
||||
(ml, false)
|
||||
} else if is_paid_active {
|
||||
(0, true)
|
||||
} else {
|
||||
(is_paid_active, is_paid_active)
|
||||
let fl: i64 = std::env::var("FREE_USER_DATA_LIMIT")
|
||||
.ok().and_then(|v| v.parse().ok()).unwrap_or(20);
|
||||
(fl, false)
|
||||
};
|
||||
|
||||
let active = if is_maintenance { true } else { is_paid_active };
|
||||
|
||||
Ok(HttpResponse::Ok().json(serde_json::json!({
|
||||
"success": true,
|
||||
"data": {
|
||||
|
||||
Reference in New Issue
Block a user