use anyhow::Result;
use async_trait::async_trait;
use std::future::Future;
use std::pin::Pin;
use crate::storage::SessionStore;
#[derive(Debug, Clone)]
#[allow(dead_code)]
pub struct SendMessage {
pub content: String,
pub recipient: String,
pub subject: Option<String>,
pub thread_ts: Option<String>,
}
impl SendMessage {
pub fn new(content: impl Into<String>, recipient: impl Into<String>) -> Self {
Self {
content: content.into(),
recipient: recipient.into(),
subject: None,
thread_ts: None,
}
}
#[allow(dead_code)]
pub fn in_thread(mut self, thread_ts: impl Into<String>) -> Self {
self.thread_ts = Some(thread_ts.into());
self
}
}
#[async_trait]
#[allow(dead_code)]
pub trait Channel {
fn name(&self) -> &'static str;
fn store(&self) -> Option<&SessionStore> {
None
}
fn run(&mut self) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>;
fn restore_sessions(&mut self, _store: SessionStore) -> Result<usize> {
Ok(0)
}
fn supports_draft_updates(&self) -> bool {
false
}
fn supports_multi_message_streaming(&self) -> bool {
false
}
fn multi_message_delay_ms(&self) -> u64 {
800
}
async fn send_draft(&mut self, _message: &SendMessage) -> Result<Option<String>> {
Ok(None)
}
async fn update_draft(
&mut self,
_recipient: &str,
_message_id: &str,
_text: &str,
) -> Result<()> {
Ok(())
}
async fn update_draft_progress(
&mut self,
_recipient: &str,
_message_id: &str,
_text: &str,
) -> Result<()> {
Ok(())
}
async fn finalize_draft(
&mut self,
_recipient: &str,
_message_id: &str,
_text: &str,
) -> Result<()> {
Ok(())
}
async fn cancel_draft(&mut self, _recipient: &str, _message_id: &str) -> Result<()> {
Ok(())
}
}