WP-02: contracts and failing tests for settings, mail, jobs and scheduler
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
58
backend/crates/application/src/settings_service.rs
Normal file
58
backend/crates/application/src/settings_service.rs
Normal file
@ -0,0 +1,58 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::jobs::JobKind;
|
||||
use domain::ports::{Cipher, Mailer, SettingsRepository};
|
||||
use domain::settings::SmtpSettings;
|
||||
use domain::DomainError;
|
||||
|
||||
pub struct SettingsService {
|
||||
repo: Arc<dyn SettingsRepository>,
|
||||
cipher: Arc<dyn Cipher>,
|
||||
mailer: Arc<dyn Mailer>,
|
||||
}
|
||||
|
||||
impl SettingsService {
|
||||
pub fn new(
|
||||
repo: Arc<dyn SettingsRepository>,
|
||||
cipher: Arc<dyn Cipher>,
|
||||
mailer: Arc<dyn Mailer>,
|
||||
) -> Self {
|
||||
let _ = (&repo, &cipher, &mailer);
|
||||
Self {
|
||||
repo,
|
||||
cipher,
|
||||
mailer,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn smtp(&self) -> Result<Option<SmtpSettings>, DomainError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn set_smtp(&self, _smtp: SmtpSettings) -> Result<(), DomainError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Send a mail to the configured recipients (or `to` if given) using the stored SMTP settings.
|
||||
pub async fn send_mail(
|
||||
&self,
|
||||
_to: Option<Vec<String>>,
|
||||
_subject: &str,
|
||||
_body: &str,
|
||||
) -> Result<(), DomainError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Cron expression (6 fields, seconds first) for a scheduled job kind, or None if disabled.
|
||||
pub async fn schedule(&self, _kind: JobKind) -> Result<Option<String>, DomainError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn set_schedule(
|
||||
&self,
|
||||
_kind: JobKind,
|
||||
_cron: Option<String>,
|
||||
) -> Result<(), DomainError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user