use entertainarr_domain::podcast::entity::PodcastTask;
use entertainarr_domain::podcast::prelude::PodcastService;
use entertainarr_domain::task::entity::TaskParams;
use entertainarr_domain::task::prelude::TaskService;

impl<MS, PS, TS, TSS> crate::Runner<MS, PS, TS, TSS>
where
    PS: PodcastService,
    TS: TaskService,
{
    pub(crate) async fn handle_podcast(
        &self,
        task: PodcastTask,
        params: &TaskParams,
    ) -> anyhow::Result<()> {
        match task {
            PodcastTask::SynchronizeAll => {
                self.podcast_service.synchronize_all(params.user_id).await
            }
            PodcastTask::Synchronize { podcast_id } => {
                self.podcast_service
                    .synchronize(params.user_id, podcast_id)
                    .await
            }
        }
    }
}
