use crate::entity::task::{TaskAttributes, TaskDocument};
impl From<entertainarr_domain::task::entity::Task> for TaskDocument {
fn from(value: entertainarr_domain::task::entity::Task) -> Self {
Self {
id: value.id,
kind: Default::default(),
attributes: TaskAttributes {
after: value.after,
status: value.status.into(),
payload: value.payload.into(),
retries: value.retries,
max_retries: value.max_retries,
created_at: value.created_at,
updated_at: value.updated_at,
},
}
}
}
impl From<entertainarr_domain::task::entity::TaskStatus> for crate::entity::task::TaskStatus {
fn from(value: entertainarr_domain::task::entity::TaskStatus) -> Self {
match value {
entertainarr_domain::task::entity::TaskStatus::Completed => Self::Completed,
entertainarr_domain::task::entity::TaskStatus::Failed { message } => {
Self::Failed { message }
}
entertainarr_domain::task::entity::TaskStatus::Pending => Self::Pending,
entertainarr_domain::task::entity::TaskStatus::Running => Self::Running,
}
}
}
impl From<entertainarr_domain::task::entity::TaskPayload> for crate::entity::task::TaskPayload {
fn from(value: entertainarr_domain::task::entity::TaskPayload) -> Self {
match value {
entertainarr_domain::task::entity::TaskPayload::Noop => Self::Noop,
entertainarr_domain::task::entity::TaskPayload::Podcast(inner) => {
Self::Podcast(inner.into())
}
_ => todo!(),
}
}
}
impl From<entertainarr_domain::podcast::entity::PodcastTask>
for crate::entity::podcast_task::PodcastTask
{
fn from(value: entertainarr_domain::podcast::entity::PodcastTask) -> Self {
match value {
entertainarr_domain::podcast::entity::PodcastTask::Synchronize { podcast_id } => {
Self::Synchronize { podcast_id }
}
_ => todo!(),
}
}
}