async fn delete(
    db: Data<PgPool>,
    algolia: ServiceData<crate::algolia::Client>,
    _claims: TokenUserWithScope<ScopeManageImage>,
    req: Path<ImageId>,
    s3: ServiceData<s3::Client>,
) -> Result<HttpResponse, error::Delete> {
    let image = req.into_inner();
    db::image::delete(&db, image)
        .await
        .map_err(check_conflict_delete)?;

    // todo: 501 when algolia is disabled.

    let delete = |kind| s3.delete_media(MediaLibrary::Global, FileKind::ImagePng(kind), image.0);
    let ((), (), (), ()) = futures::future::join4(
        delete(PngImageFile::Original),
        delete(PngImageFile::Resized),
        delete(PngImageFile::Thumbnail),
        algolia.delete_image(image),
    )
    .await;

    Ok(HttpResponse::NoContent().finish())
}
/// Delete an image from the global image library.
Delete an image from the global image library.
Delete an image from the global image library .
async fn delete(
    db: Data<PgPool>,
    algolia: ServiceData<crate::algolia::Client>,
    _claims: TokenUserWithScope<ScopeManageImage>,
    req: Path<ImageId>,
    s3: ServiceData<s3::Client>,
) -> Result<HttpResponse, error::Delete> {
    let image = req.into_inner();
    db::image::delete(&db, image)
        .await
        .map_err(check_conflict_delete)?;
    // todo: 501 when algolia is disabled.
    let delete = |kind| s3.delete_media(MediaLibrary::Global, FileKind::ImagePng(kind), image.0);
    let ((), (), (), ()) = futures::future::join4(
        delete(PngImageFile::Original),
        delete(PngImageFile::Resized),
        delete(PngImageFile::Thumbnail),
        algolia.delete_image(image),
    )
    .await;
    Ok(HttpResponse::NoContent().finish())
}
async fn delete ( db : Data < PgPool > , algolia : ServiceData < crate :: algolia :: Client > , _claims : TokenUserWithScope < ScopeManageImage > , req : Path < ImageId > , s3 : ServiceData < s3 :: Client > , ) -> Result < HttpResponse , error :: Delete > { let image = req . into_inner ( ) ; db :: image :: delete ( & db , image ) . await . map_err ( check_conflict_delete ) ? ; // todo: 501 when algolia is disabled. let delete = | kind | s3 . delete_media ( MediaLibrary :: Global , FileKind :: ImagePng ( kind ) , image . 0 ) ; let ( ( ) , ( ) , ( ) , ( ) ) = futures :: future :: join4 ( delete ( PngImageFile :: Original ) , delete ( PngImageFile :: Resized ) , delete ( PngImageFile :: Thumbnail ) , algolia . delete_image ( image ) , ) . await ; Ok ( HttpResponse :: NoContent ( ) . finish ( ) ) }
Delete an image from the global image library.
Delete an image from the global image library .
db
Data<PgPool>
algolia
ServiceData<crate::algolia::Client>
_claims
TokenUserWithScope<ScopeManageImage>
req
Path<ImageId>
s3
ServiceData<s3::Client>
db
Data<PgPool>
algolia
ServiceData<crate::algolia::Client>
_claims
TokenUserWithScope<ScopeManageImage>
req
Path<ImageId>
s3
ServiceData<s3::Client>