use color_eyre::eyre::Result; use log::info; use crate::{ context::Context, models::{album::Album, asset::Asset}, types::BulkIdsDto, }; use super::action::Action; pub struct AddAssetsToAlbum { album: Album, assets: Vec, } pub struct AddAssetsToAlbumArgs { pub album: Album, pub assets: Vec, } impl Action for AddAssetsToAlbum { type Input = AddAssetsToAlbumArgs; type Output = (); fn new(input: Self::Input) -> Self { Self { album: input.album, assets: input.assets, } } fn describe(&self) -> String { format!( "Adding {} assets to album {}", self.assets.len(), self.album.name, ) } async fn execute(&self, ctx: &Context) -> Result { info!("{}", self.describe()); if !ctx.dry_run { ctx.client .add_assets_to_album( &self.album.id, None, &BulkIdsDto { ids: self.assets.iter().map(|asset| asset.id).collect(), }, ) .await?; } Ok(()) } }