refactor(domain): Row structs for from_persistence, ID newtypes, kill clippy.toml

- delete clippy.toml (too-many-arguments-threshold=20 hack)
- ChannelRow/MediaItemRow/LibraryItemRow structs for from_persistence
- SnapshotId/ActivityEventId/PlaybackRecordId newtypes
- DomainError variants use ChannelId/UserId instead of Uuid
- ActivityEvent.channel_id: Option<ChannelId> not Option<Uuid>
- InMemory repos key on newtype IDs
- AlgorithmicParams struct for schedule engine
- update all adapters/application/presentation callers
This commit is contained in:
2026-07-12 05:00:49 +02:00
parent 031cba5cfb
commit c0e685a4ee
65 changed files with 684 additions and 695 deletions

View File

@@ -32,7 +32,7 @@ pub async fn list_my_channels(
CurrentUser(user): CurrentUser,
) -> Result<Json<Vec<ChannelResponse>>, ApiError> {
let query = ListByOwnerQuery {
owner_id: user.id().value(),
owner_id: user.id(),
};
let channels =
application::channels::list_by_owner::execute(&state.channel_query_deps, query).await?;
@@ -45,7 +45,7 @@ pub async fn create_channel(
Json(req): Json<CreateChannelRequest>,
) -> Result<Json<ChannelResponse>, ApiError> {
let cmd = CreateChannelCommand {
owner_id: user.id().value(),
owner_id: user.id(),
name: req.name,
timezone: req.timezone,
};
@@ -58,7 +58,9 @@ pub async fn get_channel(
CurrentUser(_user): CurrentUser,
Path(id): Path<uuid::Uuid>,
) -> Result<Json<ChannelResponse>, ApiError> {
let query = GetChannelQuery { channel_id: id };
let query = GetChannelQuery {
channel_id: id.into(),
};
let channel = application::channels::get::execute(&state.channel_query_deps, query)
.await?
.ok_or_else(|| ApiError::not_found(format!("Channel {id} not found")))?;
@@ -88,8 +90,8 @@ pub async fn update_channel(
.transpose()?;
let cmd = UpdateChannelCommand {
channel_id: id,
owner_id: user.id().value(),
channel_id: id.into(),
owner_id: user.id(),
name: req.name,
description: req.description.map(Some),
timezone: req.timezone,
@@ -107,8 +109,8 @@ pub async fn delete_channel(
Path(id): Path<uuid::Uuid>,
) -> Result<axum::http::StatusCode, ApiError> {
let cmd = DeleteChannelCommand {
channel_id: id,
owner_id: user.id().value(),
channel_id: id.into(),
owner_id: user.id(),
};
application::channels::delete::execute(&state.channel_command_deps, cmd).await?;
Ok(axum::http::StatusCode::NO_CONTENT)
@@ -120,7 +122,7 @@ pub async fn save_snapshot(
Path(id): Path<uuid::Uuid>,
) -> Result<Json<ConfigSnapshotResponse>, ApiError> {
let cmd = SaveSnapshotCommand {
channel_id: id,
channel_id: id.into(),
label: None,
};
let snap = application::config_snapshots::save::execute(&state.config_snapshot_deps, cmd).await?;
@@ -132,7 +134,9 @@ pub async fn list_snapshots(
CurrentUser(_user): CurrentUser,
Path(id): Path<uuid::Uuid>,
) -> Result<Json<Vec<ConfigSnapshotResponse>>, ApiError> {
let query = ListSnapshotsQuery { channel_id: id };
let query = ListSnapshotsQuery {
channel_id: id.into(),
};
let snaps = application::config_snapshots::list::execute(&state.config_snapshot_deps, query).await?;
Ok(Json(snaps.into_iter().map(ConfigSnapshotResponse::from).collect()))
}
@@ -143,8 +147,8 @@ pub async fn get_snapshot(
Path((id, snapshot_id)): Path<(uuid::Uuid, uuid::Uuid)>,
) -> Result<Json<ConfigSnapshotResponse>, ApiError> {
let query = GetSnapshotQuery {
channel_id: id,
snapshot_id,
channel_id: id.into(),
snapshot_id: snapshot_id.into(),
};
let snap = application::config_snapshots::get::execute(&state.config_snapshot_deps, query)
.await?
@@ -159,8 +163,8 @@ pub async fn patch_snapshot(
Json(req): Json<PatchSnapshotRequest>,
) -> Result<Json<ConfigSnapshotResponse>, ApiError> {
let cmd = PatchLabelCommand {
channel_id: id,
snapshot_id,
channel_id: id.into(),
snapshot_id: snapshot_id.into(),
label: req.label,
};
let snap =
@@ -176,8 +180,8 @@ pub async fn restore_snapshot(
Path((id, snapshot_id)): Path<(uuid::Uuid, uuid::Uuid)>,
) -> Result<Json<ChannelResponse>, ApiError> {
let cmd = RestoreSnapshotCommand {
channel_id: id,
snapshot_id,
channel_id: id.into(),
snapshot_id: snapshot_id.into(),
};
let channel =
application::config_snapshots::restore::execute(&state.config_snapshot_deps, cmd).await?;

View File

@@ -45,7 +45,7 @@ pub async fn get_current_broadcast(
match application::schedule::get_current_broadcast::execute(&state.schedule_deps, query).await?
{
Some(broadcast) => {
let channel_query = application::channels::GetChannelQuery { channel_id: id };
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 {