refactor: LOW+MEDIUM cleanups — CQRS DiaryQuery/GoalCommand+GoalQuery,
test-helpers out of production, decompose get_user_profile_html, dedup secure_flag, remove vestigial social_query, drop PersistedImportSession, LoginCommand rename, DeleteAccountDeps, PersonId macro, ReviewSortBy rename, TUI Command for fs::read, generic PaginatedResponse<T>, noop ports for production fallbacks
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[async_trait]
|
||||
pub trait DiaryRepository: Send + Sync {
|
||||
pub trait DiaryQuery: Send + Sync {
|
||||
async fn query_diary(&self, filter: &DiaryFilter)
|
||||
-> Result<Paginated<DiaryEntry>, DomainError>;
|
||||
async fn query_activity_feed(
|
||||
|
||||
@@ -7,10 +7,14 @@ use crate::{
|
||||
};
|
||||
|
||||
#[async_trait]
|
||||
pub trait GoalRepository: Send + Sync {
|
||||
pub trait GoalCommand: Send + Sync {
|
||||
async fn save(&self, goal: &Goal) -> Result<(), DomainError>;
|
||||
async fn update(&self, goal: &Goal) -> Result<(), DomainError>;
|
||||
async fn delete(&self, id: &GoalId, user_id: &UserId) -> Result<(), DomainError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait GoalQuery: Send + Sync {
|
||||
async fn find_by_user_and_year(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
||||
@@ -9,6 +9,7 @@ pub mod import;
|
||||
pub mod jobs;
|
||||
pub mod media_server;
|
||||
pub mod movie;
|
||||
pub mod noop;
|
||||
pub mod person;
|
||||
pub mod rss;
|
||||
pub mod search;
|
||||
|
||||
65
crates/domain/src/ports/noop.rs
Normal file
65
crates/domain/src/ports/noop.rs
Normal file
@@ -0,0 +1,65 @@
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::{errors::DomainError, value_objects::UserId};
|
||||
|
||||
// ── NoopRemoteWatchlistRepository ─────────────────────────────────────────────
|
||||
|
||||
/// Stub used when federation is disabled — every operation is a no-op.
|
||||
pub struct NoopRemoteWatchlistRepository;
|
||||
|
||||
#[async_trait]
|
||||
impl super::RemoteWatchlistRepository for NoopRemoteWatchlistRepository {
|
||||
async fn save(&self, _: crate::models::RemoteWatchlistEntry) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
async fn remove_by_ap_id(&self, _: &str, _: &str) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
async fn get_by_actor_url(
|
||||
&self,
|
||||
_: &str,
|
||||
) -> Result<Vec<crate::models::RemoteWatchlistEntry>, DomainError> {
|
||||
Ok(vec![])
|
||||
}
|
||||
async fn remove_all_by_actor(&self, _: &str) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
async fn get_by_derived_uuid(
|
||||
&self,
|
||||
_: uuid::Uuid,
|
||||
) -> Result<Vec<crate::models::RemoteWatchlistEntry>, DomainError> {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
// ── NoopSocialQueryPort ───────────────────────────────────────────────────────
|
||||
|
||||
/// Stub used when federation is disabled — returns empty results.
|
||||
pub struct NoopSocialQueryPort;
|
||||
|
||||
#[async_trait]
|
||||
impl super::SocialQueryPort for NoopSocialQueryPort {
|
||||
async fn get_accepted_following_urls(
|
||||
&self,
|
||||
_: &UserId,
|
||||
) -> Result<Vec<String>, DomainError> {
|
||||
Ok(vec![])
|
||||
}
|
||||
async fn list_all_followed_remote_actors(
|
||||
&self,
|
||||
) -> Result<Vec<crate::models::RemoteActorInfo>, DomainError> {
|
||||
Ok(vec![])
|
||||
}
|
||||
async fn count_following(&self, _: &UserId) -> Result<usize, DomainError> {
|
||||
Ok(0)
|
||||
}
|
||||
async fn count_accepted_followers(&self, _: &UserId) -> Result<usize, DomainError> {
|
||||
Ok(0)
|
||||
}
|
||||
async fn get_pending_followers(
|
||||
&self,
|
||||
_: &UserId,
|
||||
) -> Result<Vec<crate::models::PendingFollowerInfo>, DomainError> {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user