feat(mcp): implement media channel management and scheduling features

This commit is contained in:
2026-03-14 23:19:24 +01:00
parent f7f4d92376
commit c53892159a
12 changed files with 878 additions and 3 deletions

View File

@@ -0,0 +1,47 @@
use chrono::Utc;
use domain::{ScheduleEngineService, ScheduledSlot};
use serde::Serialize;
use std::sync::Arc;
use uuid::Uuid;
use crate::error::{domain_err, ok_json};
/// Serializable DTO for CurrentBroadcast (domain type does not derive Serialize).
#[derive(Serialize)]
struct CurrentBroadcastDto {
slot: ScheduledSlot,
offset_secs: u32,
}
pub async fn generate_schedule(engine: &Arc<ScheduleEngineService>, channel_id: Uuid) -> String {
match engine.generate_schedule(channel_id, Utc::now()).await {
Ok(schedule) => ok_json(&schedule),
Err(e) => domain_err(e),
}
}
pub async fn get_active_schedule(engine: &Arc<ScheduleEngineService>, channel_id: Uuid) -> String {
match engine.get_active_schedule(channel_id, Utc::now()).await {
Ok(Some(schedule)) => ok_json(&schedule),
Ok(None) => "null".to_string(),
Err(e) => domain_err(e),
}
}
pub async fn get_current_broadcast(
engine: &Arc<ScheduleEngineService>,
channel_id: Uuid,
) -> String {
let schedule = match engine.get_active_schedule(channel_id, Utc::now()).await {
Ok(Some(s)) => s,
Ok(None) => return "null".to_string(),
Err(e) => return domain_err(e),
};
match ScheduleEngineService::get_current_broadcast(&schedule, Utc::now()) {
Some(b) => ok_json(&CurrentBroadcastDto {
slot: b.slot,
offset_secs: b.offset_secs,
}),
None => "null".to_string(),
}
}