refactor: remove SocialQueryPort — replaced by SocialQuery + FederationAdminQuery
-319 lines. Legacy SocialQueryPort trait, NoopSocialQueryPort, PanicSocialQueryPort all deleted. Federation repos now implement FederationAdminQuery (single method). get_users uses FederationAdminQuery. All other consumers use unified SocialQuery.
This commit is contained in:
@@ -33,7 +33,7 @@ pub type FederationRepos = (
|
|||||||
std::sync::Arc<dyn FollowRepository>,
|
std::sync::Arc<dyn FollowRepository>,
|
||||||
std::sync::Arc<dyn ActorRepository>,
|
std::sync::Arc<dyn ActorRepository>,
|
||||||
std::sync::Arc<dyn BlocklistRepository>,
|
std::sync::Arc<dyn BlocklistRepository>,
|
||||||
std::sync::Arc<dyn domain::ports::SocialQueryPort>,
|
std::sync::Arc<dyn domain::ports::FederationAdminQuery>,
|
||||||
std::sync::Arc<dyn RemoteReviewRepository>,
|
std::sync::Arc<dyn RemoteReviewRepository>,
|
||||||
std::sync::Arc<dyn domain::ports::RemoteWatchlistRepository>,
|
std::sync::Arc<dyn domain::ports::RemoteWatchlistRepository>,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -275,10 +275,4 @@ impl SocialQuery for CompositeSocialAdapter {
|
|||||||
.map_err(ap_err)?;
|
.map_err(ap_err)?;
|
||||||
Ok(actors.into_iter().map(|a| a.url).collect())
|
Ok(actors.into_iter().map(|a| a.url).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn list_all_followed_remote_actors(
|
|
||||||
&self,
|
|
||||||
) -> Result<Vec<domain::models::RemoteActorInfo>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,14 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use domain::{
|
use domain::{
|
||||||
errors::DomainError,
|
errors::DomainError,
|
||||||
models::{PendingFollowerInfo, RemoteActorInfo},
|
models::RemoteActorInfo,
|
||||||
ports::SocialQueryPort,
|
ports::FederationAdminQuery,
|
||||||
value_objects::UserId,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PostgresFederationRepository;
|
use super::PostgresFederationRepository;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl SocialQueryPort for PostgresFederationRepository {
|
impl FederationAdminQuery for PostgresFederationRepository {
|
||||||
async fn get_accepted_following_urls(
|
|
||||||
&self,
|
|
||||||
user_id: &UserId,
|
|
||||||
) -> Result<Vec<String>, DomainError> {
|
|
||||||
let user_id_str = user_id.value().to_string();
|
|
||||||
sqlx::query_scalar::<_, String>(
|
|
||||||
"SELECT remote_actor_url FROM ap_following WHERE local_user_id = $1 AND status = 'accepted'",
|
|
||||||
).bind(&user_id_str).fetch_all(&self.pool).await
|
|
||||||
.map_err(|e| DomainError::InfrastructureError(e.to_string()))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn list_all_followed_remote_actors(&self) -> Result<Vec<RemoteActorInfo>, DomainError> {
|
async fn list_all_followed_remote_actors(&self) -> Result<Vec<RemoteActorInfo>, DomainError> {
|
||||||
let rows = sqlx::query_as::<_, (String, String, Option<String>)>(
|
let rows = sqlx::query_as::<_, (String, String, Option<String>)>(
|
||||||
"SELECT DISTINCT ar.url, ar.handle, ar.display_name FROM ap_remote_actors ar JOIN ap_following f ON f.remote_actor_url = ar.url WHERE f.status = 'accepted'",
|
"SELECT DISTINCT ar.url, ar.handle, ar.display_name FROM ap_remote_actors ar JOIN ap_following f ON f.remote_actor_url = ar.url WHERE f.status = 'accepted'",
|
||||||
@@ -34,49 +22,4 @@ impl SocialQueryPort for PostgresFederationRepository {
|
|||||||
})
|
})
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn count_following(&self, user_id: &UserId) -> Result<usize, DomainError> {
|
|
||||||
let uid = user_id.value().to_string();
|
|
||||||
let count: i64 = sqlx::query_scalar(
|
|
||||||
"SELECT COUNT(*) FROM ap_following WHERE local_user_id = $1 AND status = 'accepted'",
|
|
||||||
)
|
|
||||||
.bind(&uid)
|
|
||||||
.fetch_one(&self.pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
|
|
||||||
Ok(count as usize)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn count_accepted_followers(&self, user_id: &UserId) -> Result<usize, DomainError> {
|
|
||||||
let uid = user_id.value().to_string();
|
|
||||||
let count: i64 = sqlx::query_scalar(
|
|
||||||
"SELECT COUNT(*) FROM ap_followers WHERE local_user_id = $1 AND status = 'accepted'",
|
|
||||||
)
|
|
||||||
.bind(&uid)
|
|
||||||
.fetch_one(&self.pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
|
|
||||||
Ok(count as usize)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_pending_followers(
|
|
||||||
&self,
|
|
||||||
user_id: &UserId,
|
|
||||||
) -> Result<Vec<PendingFollowerInfo>, DomainError> {
|
|
||||||
let uid = user_id.value().to_string();
|
|
||||||
let rows = sqlx::query_as::<_, (String, String, Option<String>, Option<String>)>(
|
|
||||||
"SELECT ar.url, ar.handle, ar.display_name, ar.avatar_url FROM ap_followers f JOIN ap_remote_actors ar ON ar.url = f.remote_actor_url WHERE f.local_user_id = $1 AND f.status = 'pending'",
|
|
||||||
).bind(&uid).fetch_all(&self.pool).await.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
|
|
||||||
Ok(rows
|
|
||||||
.into_iter()
|
|
||||||
.map(
|
|
||||||
|(url, handle, display_name, avatar_url)| PendingFollowerInfo {
|
|
||||||
url,
|
|
||||||
handle,
|
|
||||||
display_name,
|
|
||||||
avatar_url,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.collect())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,14 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use domain::{
|
use domain::{
|
||||||
errors::DomainError,
|
errors::DomainError,
|
||||||
models::{PendingFollowerInfo, RemoteActorInfo},
|
models::RemoteActorInfo,
|
||||||
ports::SocialQueryPort,
|
ports::FederationAdminQuery,
|
||||||
value_objects::UserId,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SqliteFederationRepository;
|
use super::SqliteFederationRepository;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl SocialQueryPort for SqliteFederationRepository {
|
impl FederationAdminQuery for SqliteFederationRepository {
|
||||||
async fn get_accepted_following_urls(
|
|
||||||
&self,
|
|
||||||
user_id: &UserId,
|
|
||||||
) -> Result<Vec<String>, DomainError> {
|
|
||||||
let user_id_str = user_id.value().to_string();
|
|
||||||
sqlx::query_scalar::<_, String>(
|
|
||||||
"SELECT remote_actor_url FROM ap_following WHERE local_user_id = ? AND status = 'accepted'",
|
|
||||||
).bind(&user_id_str).fetch_all(&self.pool).await
|
|
||||||
.map_err(|e| DomainError::InfrastructureError(e.to_string()))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn list_all_followed_remote_actors(&self) -> Result<Vec<RemoteActorInfo>, DomainError> {
|
async fn list_all_followed_remote_actors(&self) -> Result<Vec<RemoteActorInfo>, DomainError> {
|
||||||
let rows = sqlx::query_as::<_, (String, String, Option<String>)>(
|
let rows = sqlx::query_as::<_, (String, String, Option<String>)>(
|
||||||
"SELECT DISTINCT ar.url, ar.handle, ar.display_name
|
"SELECT DISTINCT ar.url, ar.handle, ar.display_name
|
||||||
@@ -40,56 +28,4 @@ impl SocialQueryPort for SqliteFederationRepository {
|
|||||||
})
|
})
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn count_following(&self, user_id: &UserId) -> Result<usize, DomainError> {
|
|
||||||
let uid = user_id.value().to_string();
|
|
||||||
let count: i64 = sqlx::query_scalar(
|
|
||||||
"SELECT COUNT(*) FROM ap_following WHERE local_user_id = ? AND status = 'accepted'",
|
|
||||||
)
|
|
||||||
.bind(&uid)
|
|
||||||
.fetch_one(&self.pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
|
|
||||||
Ok(count as usize)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn count_accepted_followers(&self, user_id: &UserId) -> Result<usize, DomainError> {
|
|
||||||
let uid = user_id.value().to_string();
|
|
||||||
let count: i64 = sqlx::query_scalar(
|
|
||||||
"SELECT COUNT(*) FROM ap_followers WHERE local_user_id = ? AND status = 'accepted'",
|
|
||||||
)
|
|
||||||
.bind(&uid)
|
|
||||||
.fetch_one(&self.pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
|
|
||||||
Ok(count as usize)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_pending_followers(
|
|
||||||
&self,
|
|
||||||
user_id: &UserId,
|
|
||||||
) -> Result<Vec<PendingFollowerInfo>, DomainError> {
|
|
||||||
let uid = user_id.value().to_string();
|
|
||||||
let rows = sqlx::query_as::<_, (String, String, Option<String>, Option<String>)>(
|
|
||||||
"SELECT ar.url, ar.handle, ar.display_name, ar.avatar_url
|
|
||||||
FROM ap_followers f
|
|
||||||
JOIN ap_remote_actors ar ON ar.url = f.remote_actor_url
|
|
||||||
WHERE f.local_user_id = ? AND f.status = 'pending'",
|
|
||||||
)
|
|
||||||
.bind(&uid)
|
|
||||||
.fetch_all(&self.pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
|
|
||||||
Ok(rows
|
|
||||||
.into_iter()
|
|
||||||
.map(
|
|
||||||
|(url, handle, display_name, avatar_url)| PendingFollowerInfo {
|
|
||||||
url,
|
|
||||||
handle,
|
|
||||||
display_name,
|
|
||||||
avatar_url,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.collect())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use domain::ports::SocialQueryPort;
|
use domain::ports::FederationAdminQuery;
|
||||||
use k_ap::ActorRepository;
|
use k_ap::ActorRepository;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
@@ -79,30 +79,6 @@ async fn setup_db(pool: &SqlitePool) {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn test_get_accepted_following_urls_returns_only_accepted() {
|
|
||||||
let pool = SqlitePool::connect(":memory:").await.unwrap();
|
|
||||||
setup_db(&pool).await;
|
|
||||||
let repo = SqliteFederationRepository::new(pool.clone());
|
|
||||||
let user_id = uuid::Uuid::new_v4();
|
|
||||||
|
|
||||||
sqlx::query(
|
|
||||||
"INSERT INTO ap_following (local_user_id, remote_actor_url, follow_activity_id, status)
|
|
||||||
VALUES (?, 'https://other.social/users/alice', 'act1', 'accepted'),
|
|
||||||
(?, 'https://other.social/users/bob', 'act2', 'pending')",
|
|
||||||
)
|
|
||||||
.bind(user_id.to_string())
|
|
||||||
.bind(user_id.to_string())
|
|
||||||
.execute(&pool)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let uid = domain::value_objects::UserId::from_uuid(user_id);
|
|
||||||
let urls = repo.get_accepted_following_urls(&uid).await.unwrap();
|
|
||||||
assert_eq!(urls.len(), 1);
|
|
||||||
assert_eq!(urls[0], "https://other.social/users/alice");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_list_all_followed_remote_actors_deduplicates() {
|
async fn test_list_all_followed_remote_actors_deduplicates() {
|
||||||
let pool = SqlitePool::connect(":memory:").await.unwrap();
|
let pool = SqlitePool::connect(":memory:").await.unwrap();
|
||||||
|
|||||||
@@ -116,11 +116,6 @@ impl domain::ports::SocialQuery for FakeSocialWithFollowing {
|
|||||||
) -> Result<Vec<String>, DomainError> {
|
) -> Result<Vec<String>, DomainError> {
|
||||||
Ok(self.0.clone())
|
Ok(self.0.clone())
|
||||||
}
|
}
|
||||||
async fn list_all_followed_remote_actors(
|
|
||||||
&self,
|
|
||||||
) -> Result<Vec<domain::models::RemoteActorInfo>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use domain::testing::{
|
use domain::testing::{
|
||||||
InMemoryGoalRepository, InMemorySocialRepository, InMemoryWrapUpRepository,
|
InMemoryGoalRepository, InMemorySocialRepository, InMemoryWrapUpRepository,
|
||||||
InMemoryWrapUpStatsQuery, NoopSocialQueryPort,
|
InMemoryWrapUpStatsQuery, NoopFederationAdminQuery,
|
||||||
};
|
};
|
||||||
use domain::{
|
use domain::{
|
||||||
ports::{
|
ports::{
|
||||||
@@ -75,7 +75,7 @@ pub struct TestContextBuilder {
|
|||||||
pub review_logger: Arc<dyn ReviewLogger>,
|
pub review_logger: Arc<dyn ReviewLogger>,
|
||||||
pub social_command: Arc<dyn domain::ports::SocialCommand>,
|
pub social_command: Arc<dyn domain::ports::SocialCommand>,
|
||||||
pub social_query_unified: Arc<dyn domain::ports::SocialQuery>,
|
pub social_query_unified: Arc<dyn domain::ports::SocialQuery>,
|
||||||
pub social_query: Arc<dyn domain::ports::SocialQueryPort>,
|
pub federation_admin: Arc<dyn domain::ports::FederationAdminQuery>,
|
||||||
pub refresh_session_repo: Arc<dyn RefreshSessionRepository>,
|
pub refresh_session_repo: Arc<dyn RefreshSessionRepository>,
|
||||||
pub config: AppConfig,
|
pub config: AppConfig,
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ impl TestContextBuilder {
|
|||||||
review_logger: Arc::new(NoopReviewLogger),
|
review_logger: Arc::new(NoopReviewLogger),
|
||||||
social_command: Arc::clone(&social) as _,
|
social_command: Arc::clone(&social) as _,
|
||||||
social_query_unified: Arc::clone(&social) as _,
|
social_query_unified: Arc::clone(&social) as _,
|
||||||
social_query: Arc::new(NoopSocialQueryPort),
|
federation_admin: Arc::new(NoopFederationAdminQuery),
|
||||||
refresh_session_repo: InMemoryRefreshSessionRepository::new(),
|
refresh_session_repo: InMemoryRefreshSessionRepository::new(),
|
||||||
config: AppConfig {
|
config: AppConfig {
|
||||||
allow_registration: true,
|
allow_registration: true,
|
||||||
@@ -273,11 +273,6 @@ impl TestContextBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_social_query(mut self, r: Arc<dyn domain::ports::SocialQueryPort>) -> Self {
|
|
||||||
self.social_query = r;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_wrapup_repo(mut self, r: Arc<dyn WrapUpRepository>) -> Self {
|
pub fn with_wrapup_repo(mut self, r: Arc<dyn WrapUpRepository>) -> Self {
|
||||||
self.wrapup_repo = r;
|
self.wrapup_repo = r;
|
||||||
self
|
self
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use domain::ports::{
|
use domain::ports::{
|
||||||
DiaryQuery, EventPublisher, ObjectStorage, SocialQuery, SocialQueryPort, StatsRepository,
|
DiaryQuery, EventPublisher, FederationAdminQuery, ObjectStorage, SocialQuery, StatsRepository,
|
||||||
UserRepository,
|
UserRepository,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ pub struct GetProfileDeps {
|
|||||||
|
|
||||||
pub struct GetUsersListDeps {
|
pub struct GetUsersListDeps {
|
||||||
pub user: Arc<dyn UserRepository>,
|
pub user: Arc<dyn UserRepository>,
|
||||||
pub social_query_legacy: Arc<dyn SocialQueryPort>,
|
pub federation_admin: Arc<dyn FederationAdminQuery>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UpdateProfileDeps {
|
pub struct UpdateProfileDeps {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub async fn execute(
|
|||||||
) -> Result<UsersListData, DomainError> {
|
) -> Result<UsersListData, DomainError> {
|
||||||
let (users_result, actors_result) = tokio::join!(
|
let (users_result, actors_result) = tokio::join!(
|
||||||
deps.user.list_with_stats(),
|
deps.user.list_with_stats(),
|
||||||
deps.social_query_legacy.list_all_followed_remote_actors()
|
deps.federation_admin.list_all_followed_remote_actors()
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(UsersListData {
|
Ok(UsersListData {
|
||||||
|
|||||||
@@ -94,38 +94,18 @@ impl super::SocialQuery for NoopSocialQuery {
|
|||||||
async fn get_accepted_following_urls(&self, _: &UserId) -> Result<Vec<String>, DomainError> {
|
async fn get_accepted_following_urls(&self, _: &UserId) -> Result<Vec<String>, DomainError> {
|
||||||
Ok(vec![])
|
Ok(vec![])
|
||||||
}
|
}
|
||||||
async fn list_all_followed_remote_actors(
|
|
||||||
&self,
|
|
||||||
) -> Result<Vec<crate::models::RemoteActorInfo>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── NoopSocialQueryPort ───────────────────────────────────────────────────────
|
// ── NoopFederationAdminQuery ─────────────────────────────────────────────────
|
||||||
|
|
||||||
/// Stub used when federation is disabled — returns empty results.
|
/// Stub used when federation is disabled — returns empty results.
|
||||||
pub struct NoopSocialQueryPort;
|
pub struct NoopFederationAdminQuery;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl super::SocialQueryPort for NoopSocialQueryPort {
|
impl super::FederationAdminQuery for NoopFederationAdminQuery {
|
||||||
async fn get_accepted_following_urls(&self, _: &UserId) -> Result<Vec<String>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
async fn list_all_followed_remote_actors(
|
async fn list_all_followed_remote_actors(
|
||||||
&self,
|
&self,
|
||||||
) -> Result<Vec<crate::models::RemoteActorInfo>, DomainError> {
|
) -> Result<Vec<crate::models::RemoteActorInfo>, DomainError> {
|
||||||
Ok(vec![])
|
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![])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use chrono::NaiveDateTime;
|
|||||||
use crate::{
|
use crate::{
|
||||||
errors::DomainError,
|
errors::DomainError,
|
||||||
models::{
|
models::{
|
||||||
DiaryEntry, FederationFlags, PendingFollowerInfo, RemoteActorInfo, RemoteGoalEntry,
|
DiaryEntry, FederationFlags, RemoteActorInfo, RemoteGoalEntry,
|
||||||
RemoteWatchlistEntry, WatchlistWithMovie,
|
RemoteWatchlistEntry, WatchlistWithMovie,
|
||||||
},
|
},
|
||||||
value_objects::{MovieId, SocialActor, SocialIdentity, UserId},
|
value_objects::{MovieId, SocialActor, SocialIdentity, UserId},
|
||||||
@@ -94,26 +94,11 @@ pub trait SocialQuery: Send + Sync {
|
|||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
) -> Result<Vec<String>, DomainError>;
|
) -> Result<Vec<String>, DomainError>;
|
||||||
|
|
||||||
async fn list_all_followed_remote_actors(
|
|
||||||
&self,
|
|
||||||
) -> Result<Vec<crate::models::RemoteActorInfo>, DomainError>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Legacy ports (pre-unification, still used by AP adapter + handlers) ─────
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait SocialQueryPort: Send + Sync {
|
pub trait FederationAdminQuery: Send + Sync {
|
||||||
async fn get_accepted_following_urls(
|
|
||||||
&self,
|
|
||||||
user_id: &UserId,
|
|
||||||
) -> Result<Vec<String>, DomainError>;
|
|
||||||
async fn list_all_followed_remote_actors(&self) -> Result<Vec<RemoteActorInfo>, DomainError>;
|
async fn list_all_followed_remote_actors(&self) -> Result<Vec<RemoteActorInfo>, DomainError>;
|
||||||
async fn count_following(&self, user_id: &UserId) -> Result<usize, DomainError>;
|
|
||||||
async fn count_accepted_followers(&self, user_id: &UserId) -> Result<usize, DomainError>;
|
|
||||||
async fn get_pending_followers(
|
|
||||||
&self,
|
|
||||||
user_id: &UserId,
|
|
||||||
) -> Result<Vec<PendingFollowerInfo>, DomainError>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
@@ -1124,10 +1124,4 @@ impl SocialQuery for InMemorySocialRepository {
|
|||||||
) -> Result<Vec<String>, DomainError> {
|
) -> Result<Vec<String>, DomainError> {
|
||||||
Ok(vec![])
|
Ok(vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn list_all_followed_remote_actors(
|
|
||||||
&self,
|
|
||||||
) -> Result<Vec<crate::models::RemoteActorInfo>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ impl ObjectStorage for NoopObjectStorage {
|
|||||||
// Re-export production noop types so test code that imports from
|
// Re-export production noop types so test code that imports from
|
||||||
// `domain::testing` keeps compiling without changes.
|
// `domain::testing` keeps compiling without changes.
|
||||||
pub use crate::ports::noop::NoopRemoteWatchlistRepository;
|
pub use crate::ports::noop::NoopRemoteWatchlistRepository;
|
||||||
pub use crate::ports::noop::NoopSocialQueryPort;
|
pub use crate::ports::noop::NoopFederationAdminQuery;
|
||||||
|
|
||||||
// ── NoopGoalCommand ───────────────────────────────────────────────────────────
|
// ── NoopGoalCommand ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use crate::{
|
|||||||
AnnotatedRow, DiaryEntry, DiaryFilter, EntityType, ExportFormat, ExternalPersonId,
|
AnnotatedRow, DiaryEntry, DiaryFilter, EntityType, ExportFormat, ExternalPersonId,
|
||||||
FeedEntry, FeedSortBy, FieldMapping, FileFormat, FollowingFilter, ImportError,
|
FeedEntry, FeedSortBy, FieldMapping, FileFormat, FollowingFilter, ImportError,
|
||||||
ImportProfile, ImportSession, IndexableDocument, MovieProfile, MovieStats, ParsedFile,
|
ImportProfile, ImportSession, IndexableDocument, MovieProfile, MovieStats, ParsedFile,
|
||||||
PendingFollowerInfo, Person, PersonCredits, PersonEnrichmentData, PersonId, RefreshSession,
|
Person, PersonCredits, PersonEnrichmentData, PersonId, RefreshSession,
|
||||||
RemoteActorInfo, ReviewHistory, SearchQuery, SearchResults, UserStats, UserTrends,
|
RemoteActorInfo, ReviewHistory, SearchQuery, SearchResults, UserStats, UserTrends,
|
||||||
collections::{PageParams, Paginated},
|
collections::{PageParams, Paginated},
|
||||||
},
|
},
|
||||||
@@ -326,36 +326,12 @@ impl UserProfileFieldsRepository for PanicProfileFieldsRepo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PanicSocialQueryPort;
|
pub struct PanicFederationAdminQuery;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl crate::ports::SocialQueryPort for PanicSocialQueryPort {
|
impl crate::ports::FederationAdminQuery for PanicFederationAdminQuery {
|
||||||
async fn get_accepted_following_urls(
|
|
||||||
&self,
|
|
||||||
_: &crate::value_objects::UserId,
|
|
||||||
) -> Result<Vec<String>, DomainError> {
|
|
||||||
panic!("PanicSocialQueryPort called")
|
|
||||||
}
|
|
||||||
async fn list_all_followed_remote_actors(&self) -> Result<Vec<RemoteActorInfo>, DomainError> {
|
async fn list_all_followed_remote_actors(&self) -> Result<Vec<RemoteActorInfo>, DomainError> {
|
||||||
panic!("PanicSocialQueryPort called")
|
panic!("PanicFederationAdminQuery called")
|
||||||
}
|
|
||||||
async fn count_following(
|
|
||||||
&self,
|
|
||||||
_: &crate::value_objects::UserId,
|
|
||||||
) -> Result<usize, DomainError> {
|
|
||||||
panic!("PanicSocialQueryPort called")
|
|
||||||
}
|
|
||||||
async fn count_accepted_followers(
|
|
||||||
&self,
|
|
||||||
_: &crate::value_objects::UserId,
|
|
||||||
) -> Result<usize, DomainError> {
|
|
||||||
panic!("PanicSocialQueryPort called")
|
|
||||||
}
|
|
||||||
async fn get_pending_followers(
|
|
||||||
&self,
|
|
||||||
_: &crate::value_objects::UserId,
|
|
||||||
) -> Result<Vec<PendingFollowerInfo>, DomainError> {
|
|
||||||
panic!("PanicSocialQueryPort called")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use domain::ports::{
|
|||||||
MovieCommand, MovieProfileRepository, MovieQuery, ObjectStorage, PasswordHasher, PersonCommand,
|
MovieCommand, MovieProfileRepository, MovieQuery, ObjectStorage, PasswordHasher, PersonCommand,
|
||||||
PersonEnrichmentClient, PersonQuery, PosterFetcherClient, RefreshSessionRepository,
|
PersonEnrichmentClient, PersonQuery, PosterFetcherClient, RefreshSessionRepository,
|
||||||
RemoteGoalRepository, RemoteWatchlistRepository, ReviewRepository, SearchCommand, SearchPort,
|
RemoteGoalRepository, RemoteWatchlistRepository, ReviewRepository, SearchCommand, SearchPort,
|
||||||
SocialCommand, SocialQuery, SocialQueryPort, StatsRepository, UserProfileFieldsRepository,
|
FederationAdminQuery, SocialCommand, SocialQuery, StatsRepository, UserProfileFieldsRepository,
|
||||||
UserRepository, UserSettingsRepository, WatchEventCommand, WatchEventQuery,
|
UserRepository, UserSettingsRepository, WatchEventCommand, WatchEventQuery,
|
||||||
WatchlistRepository, WebhookTokenRepository, WrapUpRepository, WrapUpStatsQuery,
|
WatchlistRepository, WebhookTokenRepository, WrapUpRepository, WrapUpStatsQuery,
|
||||||
};
|
};
|
||||||
@@ -37,7 +37,7 @@ pub struct Repositories {
|
|||||||
pub remote_watchlist: Arc<dyn RemoteWatchlistRepository>,
|
pub remote_watchlist: Arc<dyn RemoteWatchlistRepository>,
|
||||||
pub social_command: Arc<dyn SocialCommand>,
|
pub social_command: Arc<dyn SocialCommand>,
|
||||||
pub social_query_unified: Arc<dyn SocialQuery>,
|
pub social_query_unified: Arc<dyn SocialQuery>,
|
||||||
pub social_query: Arc<dyn SocialQueryPort>,
|
pub federation_admin: Arc<dyn FederationAdminQuery>,
|
||||||
pub wrapup_stats: Arc<dyn WrapUpStatsQuery>,
|
pub wrapup_stats: Arc<dyn WrapUpStatsQuery>,
|
||||||
pub wrapup_repo: Arc<dyn WrapUpRepository>,
|
pub wrapup_repo: Arc<dyn WrapUpRepository>,
|
||||||
pub goal_command: Arc<dyn GoalCommand>,
|
pub goal_command: Arc<dyn GoalCommand>,
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ pub async fn update_profile_fields_handler(
|
|||||||
pub async fn list_users(State(state): State<AppState>) -> Result<Json<UsersResponse>, ApiError> {
|
pub async fn list_users(State(state): State<AppState>) -> Result<Json<UsersResponse>, ApiError> {
|
||||||
let deps = application::users::deps::GetUsersListDeps {
|
let deps = application::users::deps::GetUsersListDeps {
|
||||||
user: state.app_ctx.repos.user.clone(),
|
user: state.app_ctx.repos.user.clone(),
|
||||||
social_query_legacy: state.app_ctx.repos.social_query.clone(),
|
federation_admin: state.app_ctx.repos.federation_admin.clone(),
|
||||||
};
|
};
|
||||||
let result = get_users::execute(&deps, GetUsersQuery).await?;
|
let result = get_users::execute(&deps, GetUsersQuery).await?;
|
||||||
Ok(Json(UsersResponse {
|
Ok(Json(UsersResponse {
|
||||||
@@ -486,7 +486,7 @@ pub async fn get_users_list(
|
|||||||
|
|
||||||
let users_deps = application::users::deps::GetUsersListDeps {
|
let users_deps = application::users::deps::GetUsersListDeps {
|
||||||
user: state.app_ctx.repos.user.clone(),
|
user: state.app_ctx.repos.user.clone(),
|
||||||
social_query_legacy: state.app_ctx.repos.social_query.clone(),
|
federation_admin: state.app_ctx.repos.federation_admin.clone(),
|
||||||
};
|
};
|
||||||
match application::users::get_users::execute(
|
match application::users::get_users::execute(
|
||||||
&users_deps,
|
&users_deps,
|
||||||
|
|||||||
@@ -176,9 +176,9 @@ async fn wire_dependencies() -> anyhow::Result<(AppState, axum::Router)> {
|
|||||||
social_command: social_command_arc,
|
social_command: social_command_arc,
|
||||||
social_query_unified: social_query_unified_arc,
|
social_query_unified: social_query_unified_arc,
|
||||||
#[cfg(feature = "federation")]
|
#[cfg(feature = "federation")]
|
||||||
social_query: social_query.clone(),
|
federation_admin: social_query.clone(),
|
||||||
#[cfg(not(feature = "federation"))]
|
#[cfg(not(feature = "federation"))]
|
||||||
social_query: Arc::new(domain::ports::noop::NoopSocialQueryPort),
|
federation_admin: Arc::new(domain::ports::noop::NoopFederationAdminQuery),
|
||||||
wrapup_stats: db.wrapup_stats,
|
wrapup_stats: db.wrapup_stats,
|
||||||
wrapup_repo: db.wrapup_repo,
|
wrapup_repo: db.wrapup_repo,
|
||||||
goal_command: db.goal_command,
|
goal_command: db.goal_command,
|
||||||
|
|||||||
@@ -154,30 +154,6 @@ impl DiaryQuery for Panic {
|
|||||||
panic!()
|
panic!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl domain::ports::SocialQueryPort for Panic {
|
|
||||||
async fn get_accepted_following_urls(&self, _: &UserId) -> Result<Vec<String>, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
async fn list_all_followed_remote_actors(
|
|
||||||
&self,
|
|
||||||
) -> Result<Vec<domain::models::RemoteActorInfo>, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
async fn count_following(&self, _: &UserId) -> Result<usize, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
async fn count_accepted_followers(&self, _: &UserId) -> Result<usize, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
async fn get_pending_followers(
|
|
||||||
&self,
|
|
||||||
_: &UserId,
|
|
||||||
) -> Result<Vec<domain::models::PendingFollowerInfo>, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl StatsRepository for Panic {
|
impl StatsRepository for Panic {
|
||||||
async fn get_user_stats(&self, _: &UserId) -> Result<UserStats, DomainError> {
|
async fn get_user_stats(&self, _: &UserId) -> Result<UserStats, DomainError> {
|
||||||
@@ -813,7 +789,7 @@ pub fn make_test_state(auth_service: Arc<dyn AuthService>) -> crate::state::AppS
|
|||||||
remote_watchlist: Arc::clone(&repo) as _,
|
remote_watchlist: Arc::clone(&repo) as _,
|
||||||
social_command: Arc::new(domain::ports::noop::NoopSocialCommand) as _,
|
social_command: Arc::new(domain::ports::noop::NoopSocialCommand) as _,
|
||||||
social_query_unified: Arc::new(domain::ports::noop::NoopSocialQuery) as _,
|
social_query_unified: Arc::new(domain::ports::noop::NoopSocialQuery) as _,
|
||||||
social_query: Arc::clone(&repo) as _,
|
federation_admin: Arc::new(domain::ports::noop::NoopFederationAdminQuery) as _,
|
||||||
wrapup_stats: Arc::clone(&repo) as _,
|
wrapup_stats: Arc::clone(&repo) as _,
|
||||||
wrapup_repo: Arc::clone(&repo) as _,
|
wrapup_repo: Arc::clone(&repo) as _,
|
||||||
goal_command: Arc::clone(&repo) as _,
|
goal_command: Arc::clone(&repo) as _,
|
||||||
|
|||||||
@@ -372,9 +372,6 @@ impl SearchCommand for PanicSearchCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
struct PanicSocialQuery;
|
|
||||||
|
|
||||||
#[cfg(feature = "federation")]
|
#[cfg(feature = "federation")]
|
||||||
struct PanicRemoteWatchlist;
|
struct PanicRemoteWatchlist;
|
||||||
#[cfg(feature = "federation")]
|
#[cfg(feature = "federation")]
|
||||||
@@ -402,40 +399,6 @@ impl domain::ports::RemoteWatchlistRepository for PanicRemoteWatchlist {
|
|||||||
Ok(vec![])
|
Ok(vec![])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl domain::ports::SocialQueryPort for PanicSocialQuery {
|
|
||||||
async fn get_accepted_following_urls(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<Vec<String>, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
async fn list_all_followed_remote_actors(
|
|
||||||
&self,
|
|
||||||
) -> Result<Vec<domain::models::RemoteActorInfo>, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
async fn count_following(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<usize, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
async fn count_accepted_followers(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<usize, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
async fn get_pending_followers(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<Vec<domain::models::PendingFollowerInfo>, DomainError> {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn test_app() -> Router {
|
async fn test_app() -> Router {
|
||||||
let pool = SqlitePool::connect("sqlite::memory:")
|
let pool = SqlitePool::connect("sqlite::memory:")
|
||||||
.await
|
.await
|
||||||
@@ -466,7 +429,7 @@ async fn test_app() -> Router {
|
|||||||
remote_watchlist: Arc::new(PanicRemoteWatchlist),
|
remote_watchlist: Arc::new(PanicRemoteWatchlist),
|
||||||
social_command: Arc::new(domain::ports::noop::NoopSocialCommand),
|
social_command: Arc::new(domain::ports::noop::NoopSocialCommand),
|
||||||
social_query_unified: Arc::new(domain::ports::noop::NoopSocialQuery),
|
social_query_unified: Arc::new(domain::ports::noop::NoopSocialQuery),
|
||||||
social_query: Arc::new(PanicSocialQuery),
|
federation_admin: Arc::new(domain::ports::noop::NoopFederationAdminQuery) as _,
|
||||||
wrapup_stats: Arc::new(domain::testing::PanicWrapUpStatsQuery) as _,
|
wrapup_stats: Arc::new(domain::testing::PanicWrapUpStatsQuery) as _,
|
||||||
wrapup_repo: Arc::new(domain::testing::PanicWrapUpRepository) as _,
|
wrapup_repo: Arc::new(domain::testing::PanicWrapUpRepository) as _,
|
||||||
goal_command: Arc::new(domain::testing::NoopGoalCommand),
|
goal_command: Arc::new(domain::testing::NoopGoalCommand),
|
||||||
|
|||||||
Reference in New Issue
Block a user