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:
Per Stark
2026-05-27 13:56:32 +02:00
parent 31d585b59f
commit 9609880cff
9 changed files with 18 additions and 19 deletions
+4 -4
View File
@@ -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> {
+2 -2
View File
@@ -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(
+1 -1
View File
@@ -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(
+2 -2
View File
@@ -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(),
))
}
+3 -4
View File
@@ -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()));