Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - "main" (branch)
# - "v1.2.3" (tag)
# - "abc123def456" (commit hash)
private_chat_frontend_version = "c585b0dfd83a7e5bb6974534f0bb91b694c96e31" # v0.1.8
private_chat_frontend_version = "36f18d6ef6b326147e68990a7718b1a2397be9bf" # v0.1.8-p1

# PostHog key and host for the private-chat frontend
posthog_key = "phc_glaMeuuO1gLFSB2U9y27MchidXEmSnFOQLB8cceyVSb"
Expand Down
11 changes: 6 additions & 5 deletions crates/api/src/routes/api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/// Error message when a user is banned from using /v1/responses
const NEAR_BAN_ERROR_MESSAGE: &str =
"User is temporarily banned from using this feature; please try again later";
use crate::consts::LIST_FILES_LIMIT_MAX;
use crate::middleware::auth::AuthenticatedUser;
use axum::{
Expand Down Expand Up @@ -37,6 +34,10 @@ const NEAR_BALANCE_BAN_DURATION_SECS: i64 = 60 * 60;
/// Duration to cache NEAR balance checks in memory (in seconds)
const NEAR_BALANCE_CACHE_TTL_SECS: i64 = 5 * 60;

/// Error message when a user is banned
pub const USER_BANNED_ERROR_MESSAGE: &str =
"Access temporarily restricted. Please try again later.";

/// Create the OpenAI API proxy router
pub fn create_api_router(
rate_limit_state: crate::middleware::RateLimitState,
Expand Down Expand Up @@ -1307,7 +1308,7 @@ async fn ensure_near_balance_for_near_user(
Err((
StatusCode::FORBIDDEN,
Json(ErrorResponse {
error: NEAR_BAN_ERROR_MESSAGE.to_string(),
error: USER_BANNED_ERROR_MESSAGE.to_string(),
}),
)
.into_response())
Expand Down Expand Up @@ -1353,7 +1354,7 @@ async fn ensure_user_not_banned(
return Err((
StatusCode::FORBIDDEN,
Json(ErrorResponse {
error: NEAR_BAN_ERROR_MESSAGE.to_string(),
error: USER_BANNED_ERROR_MESSAGE.to_string(),
}),
)
.into_response());
Expand Down
3 changes: 2 additions & 1 deletion crates/api/tests/near_balance_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod common;

use api::routes::api::USER_BANNED_ERROR_MESSAGE;
use common::create_test_server;
use serde_json::json;
use tokio::time::sleep;
Expand Down Expand Up @@ -158,7 +159,7 @@ async fn test_near_balance_blocks_poor_account() {
let error = body.get("error").and_then(|v| v.as_str());
assert_eq!(
error,
Some("User is temporarily banned from using this feature; please try again later"),
Some(USER_BANNED_ERROR_MESSAGE),
"Ban error message should indicate a temporary ban without exposing NEAR balance details"
);
}