28 lines
715 B
Rust
28 lines
715 B
Rust
use domain::models::ChannelConfigSnapshot;
|
|
use domain::value_objects::ChannelId;
|
|
use domain::{DomainError, DomainResult};
|
|
|
|
use super::commands::SaveSnapshotCommand;
|
|
use super::deps::ConfigSnapshotDeps;
|
|
|
|
pub async fn execute(
|
|
deps: &ConfigSnapshotDeps,
|
|
cmd: SaveSnapshotCommand,
|
|
) -> DomainResult<ChannelConfigSnapshot> {
|
|
let channel_id = ChannelId::from(cmd.channel_id);
|
|
|
|
let channel = deps
|
|
.channel_query
|
|
.find_by_id(channel_id)
|
|
.await?
|
|
.ok_or(DomainError::ChannelNotFound(cmd.channel_id))?;
|
|
|
|
deps.channel_command
|
|
.save_config_snapshot(channel_id, channel.schedule_config(), cmd.label)
|
|
.await
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "tests/save.rs"]
|
|
mod tests;
|