Files
k-tv/crates/presentation/src/handlers/config.rs
Gabriel Kaszewski 33b440d297 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
2026-07-12 05:28:49 +02:00

30 lines
1003 B
Rust

use axum::Json;
use axum::extract::State;
use api_types::{ConfigResponse, ProviderCapabilitiesResponse, ProviderInfo};
use application::config::GetConfigQuery;
use crate::errors::AppError;
use crate::state::AppState;
pub async fn get_config(
State(state): State<AppState>,
) -> Result<Json<ConfigResponse>, AppError> {
let sys_config = application::config::get_config::execute(&state.config_deps, GetConfigQuery);
let providers: Vec<ProviderInfo> = sys_config
.providers
.into_iter()
.map(|p| ProviderInfo {
id: p.id,
capabilities: ProviderCapabilitiesResponse::from(p.capabilities),
})
.collect();
let primary_caps = ProviderCapabilitiesResponse::from(sys_config.primary_capabilities);
Ok(Json(ConfigResponse {
allow_registration: sys_config.allow_registration,
providers,
provider_capabilities: primary_caps,
available_provider_types: sys_config.available_provider_types,
}))
}