Files
movies-diary/crates/domain/src/ports/diary.rs
Gabriel Kaszewski 12da356a40 refactor: fix HIGH+MEDIUM architectural violations from code review
HIGH: fix watch_medium data-loss bug, standardize error handling on
ApiError, fix dep direction (rss/template-askama no longer dep on
application), extract ImageFetcher port (remove reqwest from app layer),
move event construction from save_review to use case, extract
infra-wiring crate (DbPool/EventBusBackend dedup), deduplicate
presentation helpers (encode_error, export streaming, multipart parsing)

MEDIUM: split LocalApContentQuery god-trait 10→3 methods, dedup movie
resolution orchestration, add RemoteActorDto/PersonDto mappers, move
AppConfig to infra-wiring, fix SocialQueryPort Uuid→UserId, replace
stringly-typed api-types with domain enums, move count_reviews_in_year
to StatsRepository, dedup event publisher cfg blocks, extract
should_enrich, move group_by_month to application, dedup
count_local_posts, add FederationFlags Default, TUI input helper +
ShowError rename + typed auth errors, api-types cleanup
(UserSettingsDto/UserProfileBase/PreviewRowData)

102 files changed, -681 lines net
2026-07-10 02:08:39 +02:00

66 lines
2.6 KiB
Rust

use async_trait::async_trait;
use crate::{
errors::DomainError,
models::{
DiaryEntry, DiaryFilter, ExportFormat, FeedEntry, FeedSortBy, FollowingFilter, MovieStats,
Review, ReviewHistory, UserStats, UserTrends,
collections::{PageParams, Paginated},
},
value_objects::{MovieId, ReviewId, UserId},
};
#[async_trait]
pub trait DiaryRepository: Send + Sync {
async fn query_diary(&self, filter: &DiaryFilter)
-> Result<Paginated<DiaryEntry>, DomainError>;
async fn query_activity_feed(
&self,
page: &PageParams,
) -> Result<Paginated<FeedEntry>, DomainError>;
async fn query_activity_feed_filtered(
&self,
page: &PageParams,
sort_by: &FeedSortBy,
search: Option<&str>,
following: Option<&FollowingFilter>,
) -> Result<Paginated<FeedEntry>, DomainError>;
async fn get_review_history(&self, movie_id: &MovieId) -> Result<ReviewHistory, DomainError>;
async fn get_user_history(&self, user_id: &UserId) -> Result<Vec<DiaryEntry>, DomainError>;
fn stream_user_history(
&self,
user_id: UserId,
) -> futures::stream::BoxStream<'static, Result<DiaryEntry, DomainError>>;
async fn get_movie_stats(&self, movie_id: &MovieId) -> Result<MovieStats, DomainError>;
async fn get_movie_social_feed(
&self,
movie_id: &MovieId,
page: &PageParams,
) -> Result<Paginated<FeedEntry>, DomainError>;
async fn count_local_posts(&self) -> Result<u64, DomainError>;
}
#[async_trait]
pub trait ReviewRepository: Send + Sync {
async fn save_review(&self, review: &Review) -> Result<(), DomainError>;
async fn get_review_by_id(&self, review_id: &ReviewId) -> Result<Option<Review>, DomainError>;
async fn update_review(&self, review: &Review) -> Result<(), DomainError>;
async fn delete_review(&self, review_id: &ReviewId) -> Result<(), DomainError>;
async fn get_all_reviews_for_user(&self, user_id: &UserId) -> Result<Vec<Review>, DomainError>;
}
#[async_trait]
pub trait StatsRepository: Send + Sync {
async fn get_user_stats(&self, user_id: &UserId) -> Result<UserStats, DomainError>;
async fn get_user_trends(&self, user_id: &UserId) -> Result<UserTrends, DomainError>;
async fn count_reviews_in_year(&self, user_id: &UserId, year: u16) -> Result<u32, DomainError>;
}
pub trait DiaryExporter: Send + Sync {
fn stream_entries(
&self,
stream: futures::stream::BoxStream<'static, Result<DiaryEntry, DomainError>>,
format: ExportFormat,
) -> futures::stream::BoxStream<'static, Result<bytes::Bytes, DomainError>>;
}