huskies: merge 639_refactor_migrate_whatsapp_transport_to_services_bundle
This commit is contained in:
@@ -18,14 +18,10 @@ pub use meta::WhatsAppTransport;
|
||||
pub use twilio::{TwilioWhatsAppTransport, extract_twilio_text_messages};
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tokio::sync::{Mutex as TokioMutex, oneshot};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::agents::AgentPool;
|
||||
use crate::chat::ChatTransport;
|
||||
use crate::http::context::{PermissionDecision, PermissionForward};
|
||||
use crate::services::Services;
|
||||
use crate::slog;
|
||||
use poem::{Request, Response, handler, http::StatusCode, web::Query};
|
||||
|
||||
@@ -110,16 +106,12 @@ pub struct VerifyQuery {
|
||||
|
||||
/// Shared context for webhook handlers, injected via Poem's `Data` extractor.
|
||||
pub struct WhatsAppWebhookContext {
|
||||
/// Shared services bundle (project root, agent pool, bot identity, permissions).
|
||||
pub services: Arc<Services>,
|
||||
pub verify_token: String,
|
||||
/// Active provider: `"meta"` (Meta Graph API) or `"twilio"` (Twilio REST API).
|
||||
pub provider: String,
|
||||
pub transport: Arc<dyn ChatTransport>,
|
||||
pub project_root: PathBuf,
|
||||
pub agents: Arc<AgentPool>,
|
||||
pub bot_name: String,
|
||||
/// The bot's "user ID" for command dispatch (e.g. "whatsapp-bot").
|
||||
pub bot_user_id: String,
|
||||
pub ambient_rooms: Arc<Mutex<HashSet<String>>>,
|
||||
/// Per-sender conversation history for LLM passthrough.
|
||||
pub history: WhatsAppConversationHistory,
|
||||
/// Maximum number of conversation entries to keep per sender.
|
||||
@@ -129,12 +121,6 @@ pub struct WhatsAppWebhookContext {
|
||||
/// Phone numbers allowed to send messages to the bot.
|
||||
/// When empty, all numbers are allowed (backwards compatible).
|
||||
pub allowed_phones: Vec<String>,
|
||||
/// Permission requests from the MCP `prompt_permission` tool arrive here.
|
||||
pub perm_rx: Arc<TokioMutex<tokio::sync::mpsc::UnboundedReceiver<PermissionForward>>>,
|
||||
/// Pending permission replies keyed by sender phone number.
|
||||
pub pending_perm_replies: Arc<TokioMutex<HashMap<String, oneshot::Sender<PermissionDecision>>>>,
|
||||
/// Seconds before an unanswered permission prompt is auto-denied.
|
||||
pub permission_timeout_secs: u64,
|
||||
}
|
||||
|
||||
/// GET /webhook/whatsapp — webhook verification.
|
||||
|
||||
Reference in New Issue
Block a user