chore: fmt + remove dead federation module
Some checks failed
CI / Check / Test (push) Failing after 5m58s

This commit is contained in:
2026-06-02 20:44:08 +02:00
parent 62fd6682c6
commit 28170c95d4
14 changed files with 107 additions and 126 deletions

View File

@@ -4,11 +4,10 @@ use domain::ports::{
AuthService, DiaryExporter, DiaryRepository, DocumentParser, EventPublisher, ImageStorage,
ImportProfileRepository, ImportSessionRepository, MetadataClient, MovieProfileRepository,
MovieRepository, PasswordHasher, PersonCommand, PersonQuery, PosterFetcherClient,
ReviewRepository, SearchCommand, SearchPort, StatsRepository, UserProfileFieldsRepository,
UserRepository, WatchEventRepository, WatchlistRepository, WebhookTokenRepository,
RemoteWatchlistRepository, ReviewRepository, SearchCommand, SearchPort, SocialQueryPort,
StatsRepository, UserProfileFieldsRepository, UserRepository, WatchEventRepository,
WatchlistRepository, WebhookTokenRepository,
};
#[cfg(feature = "federation")]
use domain::ports::{RemoteWatchlistRepository, SocialQueryPort};
use crate::config::AppConfig;
@@ -30,9 +29,7 @@ pub struct Repositories {
pub search_port: Arc<dyn SearchPort>,
pub search_command: Arc<dyn SearchCommand>,
pub profile_fields: Arc<dyn UserProfileFieldsRepository>,
#[cfg(feature = "federation")]
pub remote_watchlist: Arc<dyn RemoteWatchlistRepository>,
#[cfg(feature = "federation")]
pub social_query: Arc<dyn SocialQueryPort>,
}

View File

@@ -28,44 +28,39 @@ pub async fn execute(
}
async fn build_following_filter(
_ctx: &AppContext,
ctx: &AppContext,
query: &GetActivityFeedQuery,
) -> Option<FollowingFilter> {
#[cfg(not(feature = "federation"))]
{
let _ = query;
if !query.filter_following {
return None;
}
#[cfg(feature = "federation")]
{
if !query.filter_following {
return None;
}
let viewer_id = match query.viewer_user_id {
Some(id) => id,
None => return None,
};
let urls = _ctx
.repos
.social_query
.get_accepted_following_urls(viewer_id)
.await
.unwrap_or_default();
let base_url = &_ctx.config.base_url;
let mut local_ids = vec![viewer_id];
let mut remote_urls = Vec::new();
for url in urls {
if let Some(suffix) = url.strip_prefix(&format!("{}/users/", base_url))
&& let Ok(parsed_id) = uuid::Uuid::parse_str(suffix)
{
local_ids.push(parsed_id);
continue;
}
remote_urls.push(url);
}
Some(FollowingFilter {
local_user_ids: local_ids,
remote_actor_urls: remote_urls,
})
let viewer_id = query.viewer_user_id?;
let urls = ctx
.repos
.social_query
.get_accepted_following_urls(viewer_id)
.await
.unwrap_or_default();
if urls.is_empty() {
return Some(FollowingFilter {
local_user_ids: vec![viewer_id],
remote_actor_urls: vec![],
});
}
let base_url = &ctx.config.base_url;
let mut local_ids = vec![viewer_id];
let mut remote_urls = Vec::new();
for url in urls {
if let Some(suffix) = url.strip_prefix(&format!("{}/users/", base_url))
&& let Ok(parsed_id) = uuid::Uuid::parse_str(suffix)
{
local_ids.push(parsed_id);
continue;
}
remote_urls.push(url);
}
Some(FollowingFilter {
local_user_ids: local_ids,
remote_actor_urls: remote_urls,
})
}

View File

@@ -1,10 +0,0 @@
use domain::{errors::DomainError, models::RemoteWatchlistEntry};
use crate::context::AppContext;
pub async fn execute(
ctx: &AppContext,
uuid: uuid::Uuid,
) -> Result<Vec<RemoteWatchlistEntry>, DomainError> {
ctx.repos.remote_watchlist.get_by_derived_uuid(uuid).await
}

View File

@@ -1 +0,0 @@
pub mod get_remote_watchlist;

View File

@@ -6,8 +6,6 @@ pub mod worker;
pub mod auth;
pub mod diary;
#[cfg(feature = "federation")]
pub mod federation;
pub mod import;
pub mod integrations;
pub mod movies;

View File

@@ -1,9 +1,6 @@
use std::sync::Arc;
#[cfg(feature = "federation")]
use domain::testing::PanicRemoteWatchlistRepository;
#[cfg(feature = "federation")]
use domain::testing::PanicSocialQueryPort;
use domain::testing::{NoopRemoteWatchlistRepository, NoopSocialQueryPort};
use domain::{
ports::{
AuthService, DiaryExporter, DiaryRepository, DocumentParser, EventPublisher, ImageStorage,
@@ -145,10 +142,8 @@ impl TestContextBuilder {
person_query: self.person_query,
search_port: self.search_port,
search_command: self.search_command,
#[cfg(feature = "federation")]
remote_watchlist: Arc::new(PanicRemoteWatchlistRepository),
#[cfg(feature = "federation")]
social_query: Arc::new(PanicSocialQueryPort),
remote_watchlist: Arc::new(NoopRemoteWatchlistRepository),
social_query: Arc::new(NoopSocialQueryPort),
},
services: Services {
auth: self.auth_service,

View File

@@ -76,47 +76,40 @@ pub async fn execute(
}
async fn load_social_counts(
_ctx: &AppContext,
_user_id: uuid::Uuid,
_is_own_profile: bool,
ctx: &AppContext,
user_id: uuid::Uuid,
is_own_profile: bool,
) -> (usize, usize, Vec<PendingFollowerView>) {
#[cfg(not(feature = "federation"))]
{
(0, 0, vec![])
}
#[cfg(feature = "federation")]
{
if !_is_own_profile {
return (0, 0, vec![]);
}
let following = _ctx
.repos
.social_query
.count_following(_user_id)
.await
.unwrap_or(0);
let followers = _ctx
.repos
.social_query
.count_accepted_followers(_user_id)
.await
.unwrap_or(0);
let pending = _ctx
.repos
.social_query
.get_pending_followers(_user_id)
.await
.unwrap_or_default()
.into_iter()
.map(|p| PendingFollowerView {
url: p.url,
handle: p.handle,
display_name: p.display_name,
avatar_url: p.avatar_url,
})
.collect();
(following, followers, pending)
if !is_own_profile {
return (0, 0, vec![]);
}
let following = ctx
.repos
.social_query
.count_following(user_id)
.await
.unwrap_or(0);
let followers = ctx
.repos
.social_query
.count_accepted_followers(user_id)
.await
.unwrap_or(0);
let pending = ctx
.repos
.social_query
.get_pending_followers(user_id)
.await
.unwrap_or_default()
.into_iter()
.map(|p| PendingFollowerView {
url: p.url,
handle: p.handle,
display_name: p.display_name,
avatar_url: p.avatar_url,
})
.collect();
(following, followers, pending)
}
fn feed_sort_to_direction(sort_by: FeedSortBy) -> SortDirection {

View File

@@ -10,16 +10,10 @@ pub async fn execute(
ctx: &AppContext,
_query: GetUsersQuery,
) -> Result<UsersListData, DomainError> {
#[cfg(feature = "federation")]
let (users_result, actors_result) = tokio::join!(
ctx.repos.user.list_with_stats(),
ctx.repos.social_query.list_all_followed_remote_actors()
);
#[cfg(not(feature = "federation"))]
let (users_result, actors_result) = (
ctx.repos.user.list_with_stats().await,
Ok::<Vec<RemoteActorInfo>, DomainError>(vec![]),
);
Ok(UsersListData {
users: users_result?,

View File

@@ -55,25 +55,14 @@ pub async fn execute(
}
}
#[cfg(not(feature = "federation"))]
async fn load_remote_watchlist(
_ctx: &AppContext,
_user_id: uuid::Uuid,
) -> Result<WatchlistPageResult, DomainError> {
Ok(WatchlistPageResult {
display_entries: vec![],
has_more: false,
current_offset: 0,
limit: 0,
})
}
#[cfg(feature = "federation")]
async fn load_remote_watchlist(
ctx: &AppContext,
user_id: uuid::Uuid,
) -> Result<WatchlistPageResult, DomainError> {
let remote_entries = crate::federation::get_remote_watchlist::execute(ctx, user_id)
let remote_entries = ctx
.repos
.remote_watchlist
.get_by_derived_uuid(user_id)
.await
.unwrap_or_default();
let len = remote_entries.len() as u32;

View File

@@ -800,6 +800,33 @@ impl crate::ports::RemoteWatchlistRepository for PanicRemoteWatchlistRepository
}
}
pub struct NoopRemoteWatchlistRepository;
#[async_trait]
impl crate::ports::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![])
}
}
pub struct PanicProfileFieldsRepo;
#[async_trait]

View File

@@ -187,8 +187,12 @@ async fn wire_dependencies() -> anyhow::Result<(AppState, axum::Router)> {
profile_fields: db.profile_fields,
#[cfg(feature = "federation")]
remote_watchlist: remote_watchlist_repo,
#[cfg(not(feature = "federation"))]
remote_watchlist: Arc::new(domain::testing::NoopRemoteWatchlistRepository),
#[cfg(feature = "federation")]
social_query: social_query.clone(),
#[cfg(not(feature = "federation"))]
social_query: Arc::new(domain::testing::NoopSocialQueryPort),
},
services: Services {
auth: auth_service,

View File

@@ -591,9 +591,7 @@ pub fn make_test_state(auth_service: Arc<dyn AuthService>) -> crate::state::AppS
person_query: Arc::clone(&repo) as _,
search_port: Arc::clone(&repo) as _,
search_command: Arc::clone(&repo) as _,
#[cfg(feature = "federation")]
remote_watchlist: Arc::clone(&repo) as _,
#[cfg(feature = "federation")]
social_query: Arc::clone(&repo) as _,
},
services: Services {

View File

@@ -413,9 +413,7 @@ async fn test_app() -> Router {
person_query: Arc::new(PanicPersonQuery),
search_port: Arc::new(PanicSearchPort),
search_command: Arc::new(PanicSearchCommand),
#[cfg(feature = "federation")]
remote_watchlist: Arc::new(PanicRemoteWatchlist),
#[cfg(feature = "federation")]
social_query: Arc::new(PanicSocialQuery),
},
services: Services {

View File

@@ -86,8 +86,12 @@ async fn main() -> anyhow::Result<()> {
search_command: db.search_command,
#[cfg(feature = "federation")]
remote_watchlist: fed_remote_watchlist_repo.clone(),
#[cfg(not(feature = "federation"))]
remote_watchlist: Arc::new(domain::testing::NoopRemoteWatchlistRepository),
#[cfg(feature = "federation")]
social_query: fed_social_query,
#[cfg(not(feature = "federation"))]
social_query: Arc::new(domain::testing::NoopSocialQueryPort),
},
services: Services {
auth: auth_service,