use crate::app::AppState;
use async_trait::async_trait;
use axum::Router;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SidebarItem {
pub name: String,
pub icon: String, pub url: String,
pub permission: Option<String>, }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AddonInfo {
pub id: String,
pub name: String,
pub description: String,
pub enabled: bool,
pub config_url: Option<String>,
pub category: AddonCategory,
pub bundle: Option<String>,
pub developer: String,
pub website: String,
pub cost: String,
pub screenshots: Vec<String>,
pub restart_required: bool,
pub license_status: Option<String>,
pub license_expiry: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum AddonCategory {
Community,
Commercial,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScriptInjection {
pub url_path_regex: &'static str,
pub script_url: String,
}
#[async_trait]
pub trait Addon: Send + Sync {
fn as_any(&self) -> &dyn std::any::Any;
fn id(&self) -> &'static str;
fn name(&self) -> &'static str;
fn description(&self) -> &'static str {
""
}
fn category(&self) -> AddonCategory {
AddonCategory::Community
}
fn bundle(&self) -> Option<&'static str> {
None
}
fn developer(&self) -> &'static str {
"miuda.ai"
}
fn website(&self) -> &'static str {
""
}
fn cost(&self) -> &'static str {
"Free"
}
fn screenshots(&self) -> Vec<&'static str> {
vec![]
}
async fn initialize(&self, state: AppState) -> anyhow::Result<()>;
fn router(&self, state: AppState) -> Option<Router>;
fn sidebar_items(&self, _state: AppState) -> Vec<SidebarItem> {
vec![]
}
fn config_url(&self, state: AppState) -> Option<String> {
self.sidebar_items(state).first().map(|s| s.url.clone())
}
fn settings_items(&self) -> Option<String> {
None
}
fn inject_scripts(&self) -> Vec<ScriptInjection> {
vec![]
}
fn call_record_hook(
&self,
_db: &sea_orm::DatabaseConnection,
) -> Option<Box<dyn crate::callrecord::CallRecordHook>> {
None
}
fn proxy_server_hook(
&self,
builder: crate::proxy::server::SipServerBuilder,
_ctx: Arc<crate::app::CoreContext>,
) -> crate::proxy::server::SipServerBuilder {
builder
}
async fn seed_fixtures(&self, _state: AppState) -> anyhow::Result<()> {
Ok(())
}
}
pub mod registry;
#[cfg(feature = "addon-acme")]
pub mod acme;
#[cfg(feature = "addon-archive")]
pub mod archive;
#[cfg(feature = "addon-transcript")]
pub mod transcript;
#[cfg(feature = "addon-wholesale")]
pub mod wholesale;
pub mod queue;