diff --git a/crates/domain/src/ports.rs b/crates/domain/src/ports.rs index bfd0726..8395906 100644 --- a/crates/domain/src/ports.rs +++ b/crates/domain/src/ports.rs @@ -1,9 +1,11 @@ +use std::collections::HashMap; + use crate::{ errors::DomainError, events::{DomainEvent, EventEnvelope}, models::{ api_key::ApiKey, - feed::{FeedEntry, PageParams, Paginated, UserSummary}, + feed::{EngagementStats, FeedEntry, PageParams, Paginated, UserSummary, ViewerContext}, notification::Notification, remote_actor::RemoteActor, social::{Block, Boost, Follow, FollowState, Like}, @@ -56,6 +58,8 @@ pub trait UserReader: Send + Sync { async fn find_by_email(&self, email: &Email) -> Result, DomainError>; async fn list_with_stats(&self) -> Result, DomainError>; async fn count(&self) -> Result; + async fn list_paginated(&self, page: PageParams) -> Result, DomainError>; + async fn find_by_ids(&self, ids: &[UserId]) -> Result, DomainError>; } #[async_trait] @@ -115,6 +119,15 @@ pub trait BoostRepository: Send + Sync { async fn count_for_thought(&self, thought_id: &ThoughtId) -> Result; } +#[async_trait] +pub trait EngagementRepository: Send + Sync { + async fn get_for_thoughts( + &self, + thought_ids: &[ThoughtId], + viewer_id: Option<&UserId>, + ) -> Result)>, DomainError>; +} + #[async_trait] pub trait FollowRepository: Send + Sync { async fn save(&self, follow: &Follow) -> Result<(), DomainError>; @@ -180,6 +193,11 @@ pub trait ApiKeyRepository: Send + Sync { async fn delete(&self, id: &ApiKeyId, user_id: &UserId) -> Result<(), DomainError>; } +#[async_trait] +pub trait ApiKeyService: Send + Sync { + async fn validate_key(&self, raw_key: &str) -> Result, DomainError>; +} + #[async_trait] pub trait TopFriendRepository: Send + Sync { async fn set_top_friends(