mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 09:50:21 +08:00
fix(users): thread rate limit presence through gateway
This commit is contained in:
@@ -399,6 +399,7 @@ impl GatewayDataState {
|
|||||||
allowed_api_formats: Option<Vec<String>>,
|
allowed_api_formats: Option<Vec<String>>,
|
||||||
allowed_models_present: bool,
|
allowed_models_present: bool,
|
||||||
allowed_models: Option<Vec<String>>,
|
allowed_models: Option<Vec<String>>,
|
||||||
|
rate_limit_present: bool,
|
||||||
rate_limit: Option<i32>,
|
rate_limit: Option<i32>,
|
||||||
is_active: Option<bool>,
|
is_active: Option<bool>,
|
||||||
) -> Result<Option<StoredUserAuthRecord>, DataLayerError> {
|
) -> Result<Option<StoredUserAuthRecord>, DataLayerError> {
|
||||||
@@ -415,6 +416,7 @@ impl GatewayDataState {
|
|||||||
allowed_api_formats,
|
allowed_api_formats,
|
||||||
allowed_models_present,
|
allowed_models_present,
|
||||||
allowed_models,
|
allowed_models,
|
||||||
|
rate_limit_present,
|
||||||
rate_limit,
|
rate_limit,
|
||||||
is_active,
|
is_active,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1847,6 +1847,7 @@ impl<'a> AdminAppState<'a> {
|
|||||||
allowed_api_formats.clone(),
|
allowed_api_formats.clone(),
|
||||||
user.contains_key("allowed_models"),
|
user.contains_key("allowed_models"),
|
||||||
allowed_models.clone(),
|
allowed_models.clone(),
|
||||||
|
user.contains_key("rate_limit"),
|
||||||
rate_limit,
|
rate_limit,
|
||||||
Some(is_active),
|
Some(is_active),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ impl<'a> AdminAppState<'a> {
|
|||||||
allowed_api_formats: Option<Vec<String>>,
|
allowed_api_formats: Option<Vec<String>>,
|
||||||
allowed_models_present: bool,
|
allowed_models_present: bool,
|
||||||
allowed_models: Option<Vec<String>>,
|
allowed_models: Option<Vec<String>>,
|
||||||
|
rate_limit_present: bool,
|
||||||
rate_limit: Option<i32>,
|
rate_limit: Option<i32>,
|
||||||
is_active: Option<bool>,
|
is_active: Option<bool>,
|
||||||
) -> Result<Option<aether_data::repository::users::StoredUserAuthRecord>, GatewayError> {
|
) -> Result<Option<aether_data::repository::users::StoredUserAuthRecord>, GatewayError> {
|
||||||
@@ -179,6 +180,7 @@ impl<'a> AdminAppState<'a> {
|
|||||||
allowed_api_formats,
|
allowed_api_formats,
|
||||||
allowed_models_present,
|
allowed_models_present,
|
||||||
allowed_models,
|
allowed_models,
|
||||||
|
rate_limit_present,
|
||||||
rate_limit,
|
rate_limit,
|
||||||
is_active,
|
is_active,
|
||||||
)
|
)
|
||||||
@@ -581,4 +583,10 @@ impl<'a> AdminAppState<'a> {
|
|||||||
) -> Result<Vec<aether_data::repository::users::StoredUserExportRow>, GatewayError> {
|
) -> Result<Vec<aether_data::repository::users::StoredUserExportRow>, GatewayError> {
|
||||||
self.app.list_non_admin_export_users().await
|
self.app.list_non_admin_export_users().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn list_export_users(
|
||||||
|
&self,
|
||||||
|
) -> Result<Vec<aether_data::repository::users::StoredUserExportRow>, GatewayError> {
|
||||||
|
self.app.list_export_users().await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ pub(in super::super) async fn build_admin_update_user_response(
|
|||||||
|| field_presence.contains("allowed_providers")
|
|| field_presence.contains("allowed_providers")
|
||||||
|| field_presence.contains("allowed_api_formats")
|
|| field_presence.contains("allowed_api_formats")
|
||||||
|| field_presence.contains("allowed_models")
|
|| field_presence.contains("allowed_models")
|
||||||
|| payload.rate_limit.is_some()
|
|| field_presence.contains("rate_limit")
|
||||||
|| payload.is_active.is_some();
|
|| payload.is_active.is_some();
|
||||||
if needs_auth_user_write && !state.has_auth_user_write_capability() {
|
if needs_auth_user_write && !state.has_auth_user_write_capability() {
|
||||||
return Ok(build_admin_users_read_only_response(
|
return Ok(build_admin_users_read_only_response(
|
||||||
@@ -247,7 +247,7 @@ pub(in super::super) async fn build_admin_update_user_response(
|
|||||||
|| field_presence.contains("allowed_providers")
|
|| field_presence.contains("allowed_providers")
|
||||||
|| field_presence.contains("allowed_api_formats")
|
|| field_presence.contains("allowed_api_formats")
|
||||||
|| field_presence.contains("allowed_models")
|
|| field_presence.contains("allowed_models")
|
||||||
|| payload.rate_limit.is_some()
|
|| field_presence.contains("rate_limit")
|
||||||
|| payload.is_active.is_some()
|
|| payload.is_active.is_some()
|
||||||
{
|
{
|
||||||
if state
|
if state
|
||||||
@@ -260,6 +260,7 @@ pub(in super::super) async fn build_admin_update_user_response(
|
|||||||
allowed_api_formats,
|
allowed_api_formats,
|
||||||
field_presence.contains("allowed_models"),
|
field_presence.contains("allowed_models"),
|
||||||
allowed_models,
|
allowed_models,
|
||||||
|
field_presence.contains("rate_limit"),
|
||||||
payload.rate_limit,
|
payload.rate_limit,
|
||||||
payload.is_active,
|
payload.is_active,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ impl AppState {
|
|||||||
allowed_api_formats: Option<Vec<String>>,
|
allowed_api_formats: Option<Vec<String>>,
|
||||||
allowed_models_present: bool,
|
allowed_models_present: bool,
|
||||||
allowed_models: Option<Vec<String>>,
|
allowed_models: Option<Vec<String>>,
|
||||||
|
rate_limit_present: bool,
|
||||||
rate_limit: Option<i32>,
|
rate_limit: Option<i32>,
|
||||||
is_active: Option<bool>,
|
is_active: Option<bool>,
|
||||||
) -> Result<Option<aether_data::repository::users::StoredUserAuthRecord>, GatewayError> {
|
) -> Result<Option<aether_data::repository::users::StoredUserAuthRecord>, GatewayError> {
|
||||||
@@ -395,7 +396,7 @@ impl AppState {
|
|||||||
if let Some(is_active) = is_active {
|
if let Some(is_active) = is_active {
|
||||||
user.is_active = is_active;
|
user.is_active = is_active;
|
||||||
}
|
}
|
||||||
let _ = rate_limit;
|
let _ = (rate_limit_present, rate_limit);
|
||||||
return Ok(Some(user.clone()));
|
return Ok(Some(user.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,6 +410,7 @@ impl AppState {
|
|||||||
allowed_api_formats,
|
allowed_api_formats,
|
||||||
allowed_models_present,
|
allowed_models_present,
|
||||||
allowed_models,
|
allowed_models,
|
||||||
|
rate_limit_present,
|
||||||
rate_limit,
|
rate_limit,
|
||||||
is_active,
|
is_active,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user