domain: add RefreshSession model + repository port

This commit is contained in:
2026-06-11 14:29:43 +02:00
parent db285b513b
commit ef9ecbae06
12 changed files with 101 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
mod enrichment;
mod feed;
mod movie;
mod refresh_session;
mod review;
mod stats;
mod user;
@@ -43,6 +44,7 @@ pub use import::{
};
pub use import_profile::ImportProfile;
pub use import_session::ImportSession;
pub use refresh_session::RefreshSession;
pub use person::{
CastCredit, CrewCredit, ExternalPersonId, Person, PersonCredits, PersonEnrichmentData, PersonId,
};

View File

@@ -0,0 +1,13 @@
use chrono::{DateTime, Utc};
use uuid::Uuid;
use crate::value_objects::UserId;
#[derive(Clone, Debug)]
pub struct RefreshSession {
pub id: Uuid,
pub user_id: UserId,
pub token: String,
pub expires_at: DateTime<Utc>,
pub created_at: DateTime<Utc>,
}

View File

@@ -8,7 +8,7 @@ use crate::{
models::wrapup::WrapUpReport,
models::{
AnnotatedRow, DiaryEntry, DiaryFilter, EntityType, ExportFormat, ExternalPersonId,
FeedEntry, FieldMapping, FileFormat, Goal, ImportError, ImportProfile, ImportSession,
FeedEntry, FieldMapping, FileFormat, Goal, ImportError, ImportProfile, ImportSession, RefreshSession,
IndexableDocument, Movie, MovieFilter, MovieProfile, MovieStats, MovieSummary, ParsedFile,
ParsedPlaybackEvent, Person, PersonCredits, PersonEnrichmentData, PersonId,
RemoteGoalEntry, RemoteWatchlistEntry, Review, ReviewHistory, SearchQuery, SearchResults,
@@ -311,6 +311,15 @@ pub trait ImportSessionRepository: Send + Sync {
async fn delete_expired_for_user(&self, user_id: &UserId) -> Result<(), DomainError>;
}
#[async_trait]
pub trait RefreshSessionRepository: Send + Sync {
async fn create(&self, session: &RefreshSession) -> Result<(), DomainError>;
async fn get_by_token(&self, token: &str) -> Result<Option<RefreshSession>, DomainError>;
async fn revoke(&self, token: &str) -> Result<(), DomainError>;
async fn revoke_all_for_user(&self, user_id: &UserId) -> Result<(), DomainError>;
async fn delete_expired(&self) -> Result<u64, DomainError>;
}
#[async_trait]
pub trait ImportProfileRepository: Send + Sync {
async fn save(&self, profile: &ImportProfile) -> Result<(), DomainError>;

View File

@@ -6,15 +6,15 @@ use crate::{
AnnotatedRow, DiaryEntry, DiaryFilter, EntityType, ExportFormat, ExternalPersonId,
FeedEntry, FieldMapping, FileFormat, ImportError, ImportProfile, ImportSession,
IndexableDocument, MovieProfile, MovieStats, ParsedFile, Person, PersonCredits,
PersonEnrichmentData, PersonId, ReviewHistory, SearchQuery, SearchResults, UserStats,
UserTrends,
PersonEnrichmentData, PersonId, RefreshSession, ReviewHistory, SearchQuery, SearchResults,
UserStats, UserTrends,
collections::{PageParams, Paginated},
},
ports::{
DiaryExporter, DiaryRepository, DocumentParser, FeedSortBy, FollowingFilter,
ImportProfileRepository, ImportSessionRepository, MovieProfileRepository, PersonCommand,
PersonQuery, PosterFetcherClient, SearchCommand, SearchPort, StatsRepository,
UserProfileFieldsRepository,
PersonQuery, PosterFetcherClient, RefreshSessionRepository, SearchCommand, SearchPort,
StatsRepository, UserProfileFieldsRepository,
},
value_objects::{ImportProfileId, ImportSessionId, MovieId, PosterUrl, UserId},
};
@@ -104,6 +104,27 @@ impl ImportSessionRepository for PanicImportSessionRepository {
}
}
pub struct PanicRefreshSessionRepository;
#[async_trait]
impl RefreshSessionRepository for PanicRefreshSessionRepository {
async fn create(&self, _: &RefreshSession) -> Result<(), DomainError> {
panic!("PanicRefreshSessionRepository called")
}
async fn get_by_token(&self, _: &str) -> Result<Option<RefreshSession>, DomainError> {
panic!("PanicRefreshSessionRepository called")
}
async fn revoke(&self, _: &str) -> Result<(), DomainError> {
panic!("PanicRefreshSessionRepository called")
}
async fn revoke_all_for_user(&self, _: &UserId) -> Result<(), DomainError> {
panic!("PanicRefreshSessionRepository called")
}
async fn delete_expired(&self) -> Result<u64, DomainError> {
panic!("PanicRefreshSessionRepository called")
}
}
pub struct PanicImportProfileRepository;
#[async_trait]