feat: implement find_all method in ChannelRepository and update related services and routes for public access
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
//! Channel routes
|
||||
//!
|
||||
//! CRUD for channels and broadcast/EPG endpoints.
|
||||
//!
|
||||
//! All routes require authentication (Bearer JWT).
|
||||
//! CRUD + schedule generation require authentication (Bearer JWT).
|
||||
//! Viewing endpoints (list, now, epg, stream) are intentionally public so the
|
||||
//! TV page works without login.
|
||||
|
||||
use axum::{
|
||||
Json, Router,
|
||||
@@ -49,9 +49,8 @@ pub fn router() -> Router<AppState> {
|
||||
|
||||
async fn list_channels(
|
||||
State(state): State<AppState>,
|
||||
CurrentUser(user): CurrentUser,
|
||||
) -> Result<impl IntoResponse, ApiError> {
|
||||
let channels = state.channel_service.find_by_owner(user.id).await?;
|
||||
let channels = state.channel_service.find_all().await?;
|
||||
let response: Vec<ChannelResponse> = channels.into_iter().map(Into::into).collect();
|
||||
Ok(Json(response))
|
||||
}
|
||||
@@ -173,11 +172,9 @@ async fn get_active_schedule(
|
||||
/// Returns 204 No Content when the channel is in a gap between blocks (no-signal).
|
||||
async fn get_current_broadcast(
|
||||
State(state): State<AppState>,
|
||||
CurrentUser(user): CurrentUser,
|
||||
Path(channel_id): Path<Uuid>,
|
||||
) -> Result<Response, ApiError> {
|
||||
let channel = state.channel_service.find_by_id(channel_id).await?;
|
||||
require_owner(&channel, user.id)?;
|
||||
let _channel = state.channel_service.find_by_id(channel_id).await?;
|
||||
|
||||
let now = Utc::now();
|
||||
let schedule = state
|
||||
@@ -209,12 +206,10 @@ struct EpgQuery {
|
||||
|
||||
async fn get_epg(
|
||||
State(state): State<AppState>,
|
||||
CurrentUser(user): CurrentUser,
|
||||
Path(channel_id): Path<Uuid>,
|
||||
Query(params): Query<EpgQuery>,
|
||||
) -> Result<impl IntoResponse, ApiError> {
|
||||
let channel = state.channel_service.find_by_id(channel_id).await?;
|
||||
require_owner(&channel, user.id)?;
|
||||
let _channel = state.channel_service.find_by_id(channel_id).await?;
|
||||
|
||||
let now = Utc::now();
|
||||
let from = parse_optional_dt(params.from, now)?;
|
||||
@@ -244,11 +239,9 @@ async fn get_epg(
|
||||
/// Returns 204 No Content when the channel is in a gap (no-signal).
|
||||
async fn get_stream(
|
||||
State(state): State<AppState>,
|
||||
CurrentUser(user): CurrentUser,
|
||||
Path(channel_id): Path<Uuid>,
|
||||
) -> Result<Response, ApiError> {
|
||||
let channel = state.channel_service.find_by_id(channel_id).await?;
|
||||
require_owner(&channel, user.id)?;
|
||||
let _channel = state.channel_service.find_by_id(channel_id).await?;
|
||||
|
||||
let now = Utc::now();
|
||||
let schedule = state
|
||||
|
||||
Reference in New Issue
Block a user