Fix compilation: add Debug derive and type annotations
Some checks failed
BotServer CI / build (push) Has been cancelled
Some checks failed
BotServer CI / build (push) Has been cancelled
This commit is contained in:
parent
d22ce019b6
commit
5d3174b24e
2 changed files with 3 additions and 6 deletions
|
|
@ -161,9 +161,7 @@ impl WhatsAppAdapter {
|
||||||
language_code: &str,
|
language_code: &str,
|
||||||
components: Vec<serde_json::Value>,
|
components: Vec<serde_json::Value>,
|
||||||
) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
// Wait for rate limiter before making API call
|
// Enqueue template message
|
||||||
self.rate_limiter.acquire().await;
|
|
||||||
|
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
|
||||||
let url = format!(
|
let url = format!(
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ struct RecipientState {
|
||||||
burst_started: Option<Instant>,
|
burst_started: Option<Instant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct WhatsAppMessageQueue {
|
pub struct WhatsAppMessageQueue {
|
||||||
redis_client: redis::Client,
|
redis_client: redis::Client,
|
||||||
recipient_states: Arc<Mutex<HashMap<String, RecipientState>>>,
|
recipient_states: Arc<Mutex<HashMap<String, RecipientState>>>,
|
||||||
|
|
@ -58,7 +59,7 @@ impl WhatsAppMessageQueue {
|
||||||
let json = serde_json::to_string(&msg).map_err(|e| {
|
let json = serde_json::to_string(&msg).map_err(|e| {
|
||||||
redis::RedisError::from((redis::ErrorKind::TypeError, "JSON serialization failed", e.to_string()))
|
redis::RedisError::from((redis::ErrorKind::TypeError, "JSON serialization failed", e.to_string()))
|
||||||
})?;
|
})?;
|
||||||
conn.rpush(Self::QUEUE_KEY, json).await?;
|
conn.rpush::<_, _, ()>(Self::QUEUE_KEY, json).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,8 +145,6 @@ impl WhatsAppMessageQueue {
|
||||||
burst_started: None,
|
burst_started: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let now = Instant::now();
|
|
||||||
|
|
||||||
// Reset burst if window expired
|
// Reset burst if window expired
|
||||||
if let Some(burst_start) = state.burst_started {
|
if let Some(burst_start) = state.burst_started {
|
||||||
if burst_start.elapsed() >= Self::BURST_WINDOW {
|
if burst_start.elapsed() >= Self::BURST_WINDOW {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue