refactor: extract storage key conventions into WrapUpStorage
Some checks failed
CI / Check / Test (push) Failing after 43s
Some checks failed
CI / Check / Test (push) Failing after 43s
This commit is contained in:
@@ -2,18 +2,17 @@ use domain::errors::DomainError;
|
||||
use domain::value_objects::WrapUpId;
|
||||
|
||||
use crate::context::AppContext;
|
||||
use crate::wrapup::storage::WrapUpStorage;
|
||||
|
||||
pub async fn execute(ctx: &AppContext, id: WrapUpId) -> Result<(), DomainError> {
|
||||
let record = ctx
|
||||
.repos
|
||||
ctx.repos
|
||||
.wrapup_repo
|
||||
.get_by_id(&id)
|
||||
.await?
|
||||
.ok_or_else(|| DomainError::NotFound("wrap-up not found".into()))?;
|
||||
|
||||
let wrapup_key = format!("wrapups/{}", id.value());
|
||||
let video_key = format!("{wrapup_key}/video.mp4");
|
||||
let _ = ctx.services.image_storage.delete(&video_key).await;
|
||||
let storage = WrapUpStorage::new(ctx.services.image_storage.clone());
|
||||
let _ = storage.delete_video(&id).await;
|
||||
|
||||
ctx.repos.wrapup_repo.delete(&record.id).await
|
||||
ctx.repos.wrapup_repo.delete(&id).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user