/*
* Copyright (C) 2025 Jonni Liljamo <jonni@liljamo.com>
*
* This file is licensed under GPL-3.0-or-later, see NOTICE and LICENSE for
* more information.
*/
use async_trait::async_trait;
use crate::config::ServiceConfig;
pub mod gotify;
pub mod matrix;
#[async_trait]
pub trait Service {
async fn send(&self, title: &str, message: &str) -> Result<(), Box<dyn std::error::Error>>;
}
pub fn build(
client: reqwest::Client,
service_config: &dyn ServiceConfig,
) -> Box<dyn Service + Send + Sync> {
match service_config.typetag_name() {
"gotify" => Box::new(gotify::GotifyService::new(
client,
service_config
.as_any()
.downcast_ref::<gotify::GotifyConfig>()
.expect("fuck")
.clone(),
)),
"matrix" => Box::new(matrix::MatrixService::new(
client,
service_config
.as_any()
.downcast_ref::<matrix::MatrixConfig>()
.expect("fuck")
.clone(),
)),
_ => unreachable!(),
}
}