whatsapp_rust/handlers/
unimplemented.rs

1use super::traits::StanzaHandler;
2use crate::client::Client;
3use async_trait::async_trait;
4use std::sync::Arc;
5use wacore_binary::node::Node;
6
7/// Handler for stanza types that are not yet fully implemented.
8///
9/// This handler provides a placeholder for stanza types like:
10/// - `<call>` - Voice/video call signaling
11/// - `<presence>` - User presence updates
12/// - `<chatstate>` - Typing indicators
13///
14/// These will be logged and handled minimally until full implementations are added.
15pub struct UnimplementedHandler {
16    tags: Vec<&'static str>,
17}
18
19impl UnimplementedHandler {
20    pub fn new(tags: Vec<&'static str>) -> Self {
21        Self { tags }
22    }
23
24    pub fn for_call() -> Self {
25        Self::new(vec!["call"])
26    }
27
28    pub fn for_presence() -> Self {
29        Self::new(vec!["presence"])
30    }
31
32    pub fn for_chatstate() -> Self {
33        Self::new(vec!["chatstate"])
34    }
35}
36
37#[async_trait]
38impl StanzaHandler for UnimplementedHandler {
39    fn tag(&self) -> &'static str {
40        // For multi-tag handlers, we'll register multiple instances
41        // This method should only be called after registration
42        if self.tags.len() == 1 {
43            self.tags[0]
44        } else {
45            panic!("UnimplementedHandler with multiple tags should be registered individually")
46        }
47    }
48
49    async fn handle(&self, client: Arc<Client>, node: &Node, _cancelled: &mut bool) -> bool {
50        client.handle_unimplemented(&node.tag).await;
51        true
52    }
53}