chore: fmt + remove dead federation module
Some checks failed
CI / Check / Test (push) Failing after 5m58s
Some checks failed
CI / Check / Test (push) Failing after 5m58s
This commit is contained in:
@@ -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>,
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod get_remote_watchlist;
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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?,
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user