From 78fea8894059648c6214647c1c3273f959057839 Mon Sep 17 00:00:00 2001 From: Florian Dieminger Date: Wed, 21 Aug 2024 10:34:43 +0200 Subject: [PATCH] fix(ai-help): fix double decrement (#550) This was caused by a bad merge :/ --- src/api/ai_help.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/api/ai_help.rs b/src/api/ai_help.rs index 9d0cbaa1..35b85b6b 100644 --- a/src/api/ai_help.rs +++ b/src/api/ai_help.rs @@ -392,19 +392,7 @@ pub async fn ai_help( &mut ai_help_req_meta, ) .await; - // Reinstate the user quota if we fail to do the preparation step. - // Flagged/moderation errors DO count towards the limit, otherwise - // it is on us. - match prepare_res { - Err(crate::ai::error::AIError::OpenAIError(_)) - | Err(crate::ai::error::AIError::TiktokenError(_)) - | Err(crate::ai::error::AIError::TokenLimit) - | Err(crate::ai::error::AIError::SqlXError(_)) - | Err(crate::ai::error::AIError::NoUserPrompt) => { - let _ = decrement_limit(&mut conn, &user); - } - _ => (), - } + let user_id = user.id; match prepare_res {