fix(presentation): extract 12 handler violations to use cases

- TokenService port + JwtTokenService adapter; login/refresh return LoginResult
- delete get_token (dup of login); create_tokens helper removed
- type UpdateChannelRequest schedule_config/recycle_policy (no serde_json::Value)
- update_settings returns updated Vec; handler calls one use case
- config use case in application::config; handler maps DTO only
- SyncStatusEntry moved to api-types w/ From<LibrarySyncLogEntry>
- trigger_sync: Conflict error, drop sync_trigger.send from handler
- UpsertProviderCommand.config accepts Value; serialization in use case
- get_current_broadcast returns BroadcastWithChannel; one call
- get_stream_url resolves broadcast internally; handler single call
This commit is contained in:
2026-07-12 05:28:49 +02:00
parent 9b18d3ff6d
commit 33b440d297
44 changed files with 414 additions and 280 deletions

View File

@@ -44,20 +44,15 @@ pub async fn get_current_broadcast(
let query = GetCurrentBroadcastQuery { channel_id: id };
match application::schedule::get_current_broadcast::execute(&state.schedule_deps, query).await?
{
Some(broadcast) => {
let channel_query = application::channels::GetChannelQuery { channel_id: id.into() };
let channel = application::channels::get::execute(&state.channel_query_deps, channel_query).await?;
let slot_response = match &channel {
Some(ch) => SlotResponse::with_block_access(broadcast.slot().clone(), ch),
None => SlotResponse::from(broadcast.slot().clone()),
Some(result) => {
let slot_response = match &result.channel {
Some(ch) => SlotResponse::with_block_access(result.broadcast.slot().clone(), ch),
None => SlotResponse::from(result.broadcast.slot().clone()),
};
let block_access_mode = slot_response.block_access_mode.clone();
Ok(Json(CurrentBroadcastResponse {
slot: slot_response,
offset_secs: broadcast.offset_secs(),
offset_secs: result.broadcast.offset_secs(),
block_access_mode,
})
.into_response())
@@ -79,26 +74,13 @@ pub async fn get_stream(
State(state): State<AppState>,
Path(id): Path<uuid::Uuid>,
) -> Result<axum::response::Response, AppError> {
let broadcast_query = GetCurrentBroadcastQuery { channel_id: id };
let broadcast =
application::schedule::get_current_broadcast::execute(&state.schedule_deps, broadcast_query)
.await?;
match broadcast {
Some(b) => {
let stream_query = GetStreamUrlQuery {
channel_id: id,
item_id: b.slot().item().id().value().to_string(),
};
let url =
application::schedule::get_stream_url::execute(&state.schedule_deps, stream_query)
.await?;
Ok((
StatusCode::TEMPORARY_REDIRECT,
[("Location", url.as_str())],
)
.into_response())
}
let query = GetStreamUrlQuery { channel_id: id };
match application::schedule::get_stream_url::execute(&state.schedule_deps, query).await? {
Some(url) => Ok((
StatusCode::TEMPORARY_REDIRECT,
[("Location", url.as_str())],
)
.into_response()),
None => Ok(StatusCode::NO_CONTENT.into_response()),
}
}