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

@@ -2,54 +2,28 @@ 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;
const FALLBACK_STREAMING_PROTOCOL: &str = "direct_file";
pub async fn get_config(
State(state): State<AppState>,
) -> Result<Json<ConfigResponse>, AppError> {
let registry = &state.provider_registry;
let provider_ids = registry.provider_ids();
let primary_id = registry.primary_id().to_string();
let providers: Vec<ProviderInfo> = provider_ids
.iter()
.filter_map(|id| {
registry.capabilities(id).map(|caps| ProviderInfo {
id: id.clone(),
capabilities: ProviderCapabilitiesResponse::from(caps),
})
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 = registry
.capabilities(&primary_id)
.map(ProviderCapabilitiesResponse::from)
.unwrap_or(ProviderCapabilitiesResponse {
collections: false,
series: false,
genres: false,
tags: false,
decade: false,
search: false,
streaming_protocol: FALLBACK_STREAMING_PROTOCOL.to_string(),
rescan: false,
transcode: false,
});
let mut available_types = Vec::new();
#[cfg(feature = "jellyfin")]
available_types.push("jellyfin".to_string());
#[cfg(feature = "local-files")]
available_types.push("local_files".to_string());
let primary_caps = ProviderCapabilitiesResponse::from(sys_config.primary_capabilities);
Ok(Json(ConfigResponse {
allow_registration: state.config.allow_registration,
allow_registration: sys_config.allow_registration,
providers,
provider_capabilities: primary_caps,
available_provider_types: available_types,
available_provider_types: sys_config.available_provider_types,
}))
}