fix(chat): resolve compilation errors and clean all warnings
- Replace ChatError::AuthError (nonexistent variant) with InvalidToken and ServiceUnavailable in jwt_manager.rs - Remove unused imports: ExchangeDeclareOptions, ExchangeKind (event_bus), StatusCode (request_id), warn (typing_indicator), AsyncCommands (rate_limiter) - Fix unnecessary mut: delivered_status.rs, read_receipts.rs - Prefix unused struct fields: _config, _connection (event_bus), _secret (csrf) - Prefix unused variables: _metadata, parent_message_id: _ (handler.rs), user_id: _ (permission.rs) - Allow dead_code on GetMessagesQuery and exchange_kind_from_str Chat server now compiles with zero errors and zero warnings. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
09bb663659
commit
9b65e40952
11 changed files with 25 additions and 27 deletions
|
|
@ -54,7 +54,7 @@ impl DeliveredStatusManager {
|
|||
.fetch_optional(&self.pool)
|
||||
.await?;
|
||||
|
||||
if let Some(mut status) = existing {
|
||||
if let Some(status) = existing {
|
||||
// Mettre à jour le timestamp de délivrance
|
||||
let updated = sqlx::query_as::<_, DeliveredStatus>(
|
||||
"UPDATE delivered_status
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
use lapin::{
|
||||
options::ExchangeDeclareOptions, types::FieldTable, Channel, Connection, ConnectionProperties,
|
||||
ExchangeKind,
|
||||
};
|
||||
use lapin::{types::FieldTable, Channel, Connection, ConnectionProperties};
|
||||
use tokio::time::{sleep, Duration};
|
||||
use tracing::{error, info, warn};
|
||||
|
||||
|
|
@ -27,8 +24,8 @@ impl EventBusUnavailableError {
|
|||
|
||||
/// Gestionnaire de connexion RabbitMQ
|
||||
pub struct RabbitMQEventBus {
|
||||
config: config::RabbitMQConfig, // Use the canonical config type
|
||||
connection: Option<Connection>,
|
||||
_config: config::RabbitMQConfig, // Use the canonical config type
|
||||
_connection: Option<Connection>,
|
||||
channel: Option<Channel>,
|
||||
pub is_enabled: bool,
|
||||
}
|
||||
|
|
@ -39,8 +36,8 @@ impl RabbitMQEventBus {
|
|||
if !config.enable {
|
||||
info!("📴 EventBus RabbitMQ désactivé par configuration.");
|
||||
return Ok(Self {
|
||||
config,
|
||||
connection: None,
|
||||
_config: config,
|
||||
_connection: None,
|
||||
channel: None,
|
||||
is_enabled: false,
|
||||
});
|
||||
|
|
@ -65,8 +62,8 @@ impl RabbitMQEventBus {
|
|||
ChatError::internal_error(format!("Failed to open RabbitMQ channel: {}", e))
|
||||
})?;
|
||||
return Ok(Self {
|
||||
config,
|
||||
connection: Some(conn),
|
||||
_config: config,
|
||||
_connection: Some(conn),
|
||||
channel: Some(channel),
|
||||
is_enabled: true,
|
||||
});
|
||||
|
|
@ -196,6 +193,7 @@ impl RabbitMQEventBus {
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn exchange_kind_from_str(s: &str) -> lapin::ExchangeKind {
|
||||
match s.to_lowercase().as_str() {
|
||||
"direct" => lapin::ExchangeKind::Direct,
|
||||
|
|
|
|||
|
|
@ -411,9 +411,9 @@ impl JwtManager {
|
|||
user_id = %claims.user_id,
|
||||
"User not found in DB during token refresh — rejecting token"
|
||||
);
|
||||
return Err(ChatError::AuthError(
|
||||
"User no longer exists — token refresh denied".to_string(),
|
||||
));
|
||||
return Err(ChatError::InvalidToken {
|
||||
reason: "User no longer exists — token refresh denied".to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -421,9 +421,10 @@ impl JwtManager {
|
|||
user_id = %claims.user_id,
|
||||
"No DB pool available for token refresh — rejecting token"
|
||||
);
|
||||
return Err(ChatError::AuthError(
|
||||
"Database unavailable — token refresh denied".to_string(),
|
||||
));
|
||||
return Err(ChatError::ServiceUnavailable {
|
||||
service: "database".to_string(),
|
||||
reason: "Database unavailable — token refresh denied".to_string(),
|
||||
});
|
||||
};
|
||||
|
||||
// MIGRATION UUID: Cloner user_id avant de le move
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ struct SendMessageRequest {
|
|||
|
||||
/// Paramètres de récupération de messages
|
||||
#[derive(Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
struct GetMessagesQuery {
|
||||
conversation_id: Uuid,
|
||||
limit: Option<i64>,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use axum::{
|
||||
extract::Request,
|
||||
http::{HeaderMap, HeaderName, HeaderValue, StatusCode},
|
||||
http::{HeaderMap, HeaderName, HeaderValue},
|
||||
middleware::Next,
|
||||
response::Response,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ impl ReadReceiptManager {
|
|||
.fetch_optional(&self.pool)
|
||||
.await?;
|
||||
|
||||
if let Some(mut receipt) = existing {
|
||||
if let Some(receipt) = existing {
|
||||
// Mettre à jour le timestamp de lecture
|
||||
let updated = sqlx::query_as::<_, ReadReceipt>(
|
||||
"UPDATE read_receipts
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ pub struct CsrfManager {
|
|||
/// Tokens CSRF actifs (jti -> session_id)
|
||||
active_tokens: Arc<RwLock<HashMap<String, String>>>,
|
||||
/// Configuration
|
||||
secret: String,
|
||||
_secret: String,
|
||||
/// Durée de vie des tokens CSRF (en secondes)
|
||||
token_lifetime: i64,
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ impl CsrfManager {
|
|||
decoding_key,
|
||||
validation,
|
||||
active_tokens: Arc::new(RwLock::new(HashMap::new())),
|
||||
secret,
|
||||
_secret: secret,
|
||||
token_lifetime,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ impl From<PermissionError> for ChatError {
|
|||
fn from(err: PermissionError) -> Self {
|
||||
match err {
|
||||
PermissionError::NotMember {
|
||||
user_id,
|
||||
user_id: _,
|
||||
conversation_id,
|
||||
} => ChatError::NotMember {
|
||||
conversation_id: conversation_id.to_string(),
|
||||
|
|
|
|||
|
|
@ -165,8 +165,6 @@ impl RateLimiter {
|
|||
action: &RateLimitAction,
|
||||
config: &RateLimitConfig,
|
||||
) -> Result<bool, String> {
|
||||
use redis::AsyncCommands;
|
||||
|
||||
let key = format!("rl:chat:{}:{}", user_id, action.redis_key_suffix());
|
||||
let window_secs = config.window.as_secs().max(1);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use chrono::{Duration, Utc};
|
|||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
use tracing::{debug, info, instrument, warn};
|
||||
use tracing::{debug, info, instrument};
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Représente un changement de statut typing pour un utilisateur
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ async fn handle_incoming_message(
|
|||
IncomingMessage::SendMessage {
|
||||
conversation_id,
|
||||
content,
|
||||
parent_message_id,
|
||||
parent_message_id: _,
|
||||
attachments,
|
||||
} => {
|
||||
info!(
|
||||
|
|
@ -333,7 +333,7 @@ async fn handle_incoming_message(
|
|||
})?;
|
||||
|
||||
// Préparer les métadonnées pour les pièces jointes
|
||||
let metadata = attachments.as_ref().map(|a| serde_json::to_value(a).unwrap_or(serde_json::Value::Null));
|
||||
let _metadata = attachments.as_ref().map(|a| serde_json::to_value(a).unwrap_or(serde_json::Value::Null));
|
||||
|
||||
// Enregistrer le message dans le store
|
||||
// Note: On pourrait étendre MessageRepository::create pour accepter metadata et parent_message_id
|
||||
|
|
|
|||
Loading…
Reference in a new issue