feat: goals — "watch N movies in YEAR" with progress bar
Domain: Goal entity, UserSettings (federation toggle), RemoteGoalEntry.
Ports: GoalRepository, UserSettingsRepository, RemoteGoalRepository.
Adapters: sqlite + postgres repos, migrations, AP content query extensions.
Application: CRUD use cases (create/update/delete/get/list), settings use cases.
API: 7 endpoints (/goals CRUD, /users/{id}/goals, /settings) with utoipa docs.
Federation: GoalObject (Note + goal discriminator), outbound broadcast with
per-user toggle, inbound GoalObjectHandler in CompositeObjectHandler.
SPA: API client + hooks, GoalCard (shadcn Card+Progress+DropdownMenu),
GoalSheet (Drawer), profile integration (editable own, read-only others),
federation toggle in settings (Switch).
Classic HTML: glassmorphic goal card on profile, Frutiger Aero styling.
Progress computed from existing reviews — backwards compatible.
This commit is contained in:
8
crates/application/src/users/get_settings.rs
Normal file
8
crates/application/src/users/get_settings.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use domain::{errors::DomainError, models::UserSettings, value_objects::UserId};
|
||||
|
||||
use crate::context::AppContext;
|
||||
|
||||
pub async fn execute(ctx: &AppContext, user_id: uuid::Uuid) -> Result<UserSettings, DomainError> {
|
||||
let uid = UserId::from_uuid(user_id);
|
||||
ctx.repos.user_settings.get(&uid).await
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
pub mod commands;
|
||||
pub mod get_current_profile;
|
||||
pub mod get_profile;
|
||||
pub mod get_settings;
|
||||
pub mod get_users;
|
||||
pub mod queries;
|
||||
pub mod update_profile;
|
||||
pub mod update_profile_fields;
|
||||
pub mod update_settings;
|
||||
|
||||
15
crates/application/src/users/update_settings.rs
Normal file
15
crates/application/src/users/update_settings.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use domain::{errors::DomainError, value_objects::UserId};
|
||||
|
||||
use crate::context::AppContext;
|
||||
|
||||
pub struct UpdateUserSettingsCommand {
|
||||
pub user_id: uuid::Uuid,
|
||||
pub federate_goals: bool,
|
||||
}
|
||||
|
||||
pub async fn execute(ctx: &AppContext, cmd: UpdateUserSettingsCommand) -> Result<(), DomainError> {
|
||||
let uid = UserId::from_uuid(cmd.user_id);
|
||||
let mut settings = ctx.repos.user_settings.get(&uid).await?;
|
||||
settings.set_federate_goals(cmd.federate_goals);
|
||||
ctx.repos.user_settings.save(&settings).await
|
||||
}
|
||||
Reference in New Issue
Block a user