mirror of
https://github.com/perstarkse/minne.git
synced 2026-05-28 10:29:30 +02:00
fix: revoke_api_key sets NONE, remove unused bind, lowercase error msgs
- fix bug where revoke_api_key set literal 'test_string_nullish' instead of NONE - remove unused table_name bind in update_timezone - lowercase ~16 error messages across 4 crates
This commit is contained in:
@@ -34,7 +34,7 @@ impl Analytics {
|
||||
|
||||
let stored: Option<Self> = db.store_item(created_analytics).await?;
|
||||
return stored.ok_or(AppError::Validation(
|
||||
"Failed to initialize analytics".into(),
|
||||
"failed to initialize analytics".into(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ impl Analytics {
|
||||
}
|
||||
pub async fn get_current(db: &SurrealDbClient) -> Result<Self, AppError> {
|
||||
let analytics: Option<Self> = db.get_item("current").await?;
|
||||
analytics.ok_or(AppError::NotFound("Analytics not found".into()))
|
||||
analytics.ok_or(AppError::NotFound("analytics not found".into()))
|
||||
}
|
||||
|
||||
pub async fn increment_visitors(db: &SurrealDbClient) -> Result<Self, AppError> {
|
||||
@@ -54,7 +54,7 @@ impl Analytics {
|
||||
.await?
|
||||
.take(0)?;
|
||||
|
||||
updated.ok_or(AppError::Validation("Failed to update analytics".into()))
|
||||
updated.ok_or(AppError::Validation("failed to update analytics".into()))
|
||||
}
|
||||
|
||||
pub async fn increment_page_loads(db: &SurrealDbClient) -> Result<Self, AppError> {
|
||||
@@ -64,7 +64,7 @@ impl Analytics {
|
||||
.await?
|
||||
.take(0)?;
|
||||
|
||||
updated.ok_or(AppError::Validation("Failed to update analytics".into()))
|
||||
updated.ok_or(AppError::Validation("failed to update analytics".into()))
|
||||
}
|
||||
|
||||
pub async fn get_users_amount(db: &SurrealDbClient) -> Result<i64, AppError> {
|
||||
|
||||
@@ -79,7 +79,7 @@ impl Conversation {
|
||||
let conversation: Conversation = db
|
||||
.get_item(conversation_id)
|
||||
.await?
|
||||
.ok_or_else(|| AppError::NotFound("Conversation not found".to_string()))?;
|
||||
.ok_or_else(|| AppError::NotFound("conversation not found".to_string()))?;
|
||||
|
||||
if conversation.user_id != user_id {
|
||||
return Err(AppError::Auth(
|
||||
@@ -105,7 +105,7 @@ impl Conversation {
|
||||
// First verify ownership by getting conversation user_id
|
||||
let conversation: Option<Conversation> = db.get_item(id).await?;
|
||||
let conversation =
|
||||
conversation.ok_or_else(|| AppError::NotFound("Conversation not found".to_string()))?;
|
||||
conversation.ok_or_else(|| AppError::NotFound("conversation not found".to_string()))?;
|
||||
|
||||
if conversation.user_id != user_id {
|
||||
return Err(AppError::Auth(
|
||||
|
||||
@@ -78,7 +78,7 @@ impl Scratchpad {
|
||||
let scratchpad: Option<Scratchpad> = db.get_item(id).await?;
|
||||
|
||||
let scratchpad =
|
||||
scratchpad.ok_or_else(|| AppError::NotFound("Scratchpad not found".to_string()))?;
|
||||
scratchpad.ok_or_else(|| AppError::NotFound("scratchpad not found".to_string()))?;
|
||||
|
||||
if scratchpad.user_id != user_id {
|
||||
return Err(AppError::Auth(
|
||||
|
||||
@@ -36,7 +36,7 @@ impl StoredObject for SystemSettings {
|
||||
impl SystemSettings {
|
||||
pub async fn get_current(db: &SurrealDbClient) -> Result<Self, AppError> {
|
||||
let settings: Option<Self> = db.get_item("current").await?;
|
||||
settings.ok_or(AppError::NotFound("System settings not found".into()))
|
||||
settings.ok_or(AppError::NotFound("system settings not found".into()))
|
||||
}
|
||||
|
||||
pub async fn update(db: &SurrealDbClient, changes: Self) -> Result<Self, AppError> {
|
||||
@@ -49,7 +49,7 @@ impl SystemSettings {
|
||||
.take(0)?;
|
||||
|
||||
updated.ok_or(AppError::Validation(
|
||||
"Something went wrong updating the settings".into(),
|
||||
"something went wrong updating the settings".into(),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -371,7 +371,7 @@ impl User {
|
||||
.client
|
||||
.query(
|
||||
"UPDATE type::thing('user', $id)
|
||||
SET api_key = test_string_nullish
|
||||
SET api_key = NONE
|
||||
RETURN AFTER",
|
||||
)
|
||||
.bind(("id", id.to_owned()))
|
||||
@@ -532,7 +532,6 @@ impl User {
|
||||
db: &SurrealDbClient,
|
||||
) -> Result<(), AppError> {
|
||||
db.query("UPDATE type::thing('user', $user_id) SET timezone = $timezone")
|
||||
.bind(("table_name", Self::table_name()))
|
||||
.bind(("user_id", user_id.to_string()))
|
||||
.bind(("timezone", timezone.to_string()))
|
||||
.await?;
|
||||
@@ -579,7 +578,7 @@ impl User {
|
||||
let entity: KnowledgeEntity = db
|
||||
.get_item(id)
|
||||
.await?
|
||||
.ok_or_else(|| AppError::NotFound("Entity not found".into()))?;
|
||||
.ok_or_else(|| AppError::NotFound("entity not found".into()))?;
|
||||
|
||||
if entity.user_id != user_id {
|
||||
return Err(AppError::Auth("Access denied".into()));
|
||||
@@ -596,7 +595,7 @@ impl User {
|
||||
let text_content: TextContent = db
|
||||
.get_item(id)
|
||||
.await?
|
||||
.ok_or_else(|| AppError::NotFound("Content not found".into()))?;
|
||||
.ok_or_else(|| AppError::NotFound("content not found".into()))?;
|
||||
|
||||
if text_content.user_id != user_id {
|
||||
return Err(AppError::Auth("Access denied".into()));
|
||||
|
||||
@@ -148,7 +148,7 @@ pub async fn new_user_message(
|
||||
.db
|
||||
.get_item(&conversation_id)
|
||||
.await?
|
||||
.ok_or_else(|| AppError::NotFound("Conversation was not found".into()))?;
|
||||
.ok_or_else(|| AppError::NotFound("conversation was not found".into()))?;
|
||||
|
||||
if conversation.user_id != user.id {
|
||||
return Ok(TemplateResponse::unauthorized().into_response());
|
||||
@@ -235,7 +235,7 @@ pub async fn show_conversation_editing_title(
|
||||
.db
|
||||
.get_item(&conversation_id)
|
||||
.await?
|
||||
.ok_or_else(|| AppError::NotFound("Conversation not found".to_string()))?;
|
||||
.ok_or_else(|| AppError::NotFound("conversation not found".to_string()))?;
|
||||
|
||||
if conversation.user_id != user.id {
|
||||
return Ok(TemplateResponse::unauthorized().into_response());
|
||||
@@ -277,7 +277,7 @@ pub async fn delete_conversation(
|
||||
.db
|
||||
.get_item(&conversation_id)
|
||||
.await?
|
||||
.ok_or_else(|| AppError::NotFound("Conversation not found".to_string()))?;
|
||||
.ok_or_else(|| AppError::NotFound("conversation not found".to_string()))?;
|
||||
|
||||
if conversation.user_id != user.id {
|
||||
return Ok(TemplateResponse::unauthorized().into_response());
|
||||
|
||||
@@ -113,7 +113,7 @@ async fn get_and_validate_text_content(
|
||||
.db
|
||||
.get_item::<TextContent>(id)
|
||||
.await?
|
||||
.ok_or_else(|| AppError::NotFound("Item was not found".to_string()))?;
|
||||
.ok_or_else(|| AppError::NotFound("item was not found".to_string()))?;
|
||||
|
||||
if text_content.user_id != user.id {
|
||||
return Err(AppError::Auth(
|
||||
|
||||
@@ -173,7 +173,7 @@ pub async fn create_knowledge_entity(
|
||||
) -> Result<impl IntoResponse, HtmlError> {
|
||||
let name = form.name.trim().to_string();
|
||||
if name.is_empty() {
|
||||
return Err(AppError::Validation("Name is required".into()).into());
|
||||
return Err(AppError::Validation("name is required".into()).into());
|
||||
}
|
||||
|
||||
let description = form.description.trim().to_string();
|
||||
|
||||
@@ -75,7 +75,7 @@ pub async fn extract_text_from_url(
|
||||
}
|
||||
|
||||
let parsed_url =
|
||||
url::Url::parse(url).map_err(|_| AppError::Validation("Invalid URL".to_string()))?;
|
||||
url::Url::parse(url).map_err(|_| AppError::Validation("invalid URL".to_string()))?;
|
||||
|
||||
let domain = ensure_ingestion_url_allowed(&parsed_url)?;
|
||||
let timestamp = Utc::now().format("%Y%m%d%H%M%S");
|
||||
|
||||
Reference in New Issue
Block a user