use uuid::Uuid;
use super::WhatsAppState;
impl WhatsAppState {
pub async fn set_pending_followups(&self, session_id: Uuid, options: Vec<String>) {
self.pending_followups
.lock()
.await
.insert(session_id, options);
}
pub async fn take_followup_by_reply(&self, session_id: Uuid, reply: &str) -> Option<String> {
let parsed: usize = reply.trim().parse().ok()?;
if parsed == 0 {
return None;
}
let mut map = self.pending_followups.lock().await;
let options = map.get(&session_id)?;
let chosen = options.get(parsed - 1).cloned();
if chosen.is_some() {
map.remove(&session_id);
}
chosen
}
pub async fn clear_pending_followups(&self, session_id: Uuid) {
self.pending_followups.lock().await.remove(&session_id);
}
}