refactor(import): scoped Arc deps, ImportSessionCleanupJob

This commit is contained in:
2026-06-11 21:49:15 +02:00
parent b552c1d156
commit b5ff43d9dc
19 changed files with 198 additions and 215 deletions

View File

@@ -1,19 +1,24 @@
use crate::{context::AppContext, import::commands::DeleteImportProfileCommand};
use std::sync::Arc;
use crate::import::commands::DeleteImportProfileCommand;
use domain::{
errors::DomainError,
ports::ImportProfileRepository,
value_objects::{ImportProfileId, UserId},
};
pub async fn execute(ctx: &AppContext, cmd: DeleteImportProfileCommand) -> Result<(), DomainError> {
pub async fn execute(
import_profile: Arc<dyn ImportProfileRepository>,
cmd: DeleteImportProfileCommand,
) -> Result<(), DomainError> {
let user_id = UserId::from_uuid(cmd.user_id);
let profile_id = ImportProfileId::from_uuid(cmd.profile_id);
ctx.repos
.import_profile
import_profile
.get(&profile_id, &user_id)
.await?
.ok_or_else(|| DomainError::NotFound("import profile".into()))?;
ctx.repos.import_profile.delete(&profile_id).await
import_profile.delete(&profile_id).await
}
#[cfg(test)]