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,
|
AuthService, DiaryExporter, DiaryRepository, DocumentParser, EventPublisher, ImageStorage,
|
||||||
ImportProfileRepository, ImportSessionRepository, MetadataClient, MovieProfileRepository,
|
ImportProfileRepository, ImportSessionRepository, MetadataClient, MovieProfileRepository,
|
||||||
MovieRepository, PasswordHasher, PersonCommand, PersonQuery, PosterFetcherClient,
|
MovieRepository, PasswordHasher, PersonCommand, PersonQuery, PosterFetcherClient,
|
||||||
ReviewRepository, SearchCommand, SearchPort, StatsRepository, UserProfileFieldsRepository,
|
RemoteWatchlistRepository, ReviewRepository, SearchCommand, SearchPort, SocialQueryPort,
|
||||||
UserRepository, WatchEventRepository, WatchlistRepository, WebhookTokenRepository,
|
StatsRepository, UserProfileFieldsRepository, UserRepository, WatchEventRepository,
|
||||||
|
WatchlistRepository, WebhookTokenRepository,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
use domain::ports::{RemoteWatchlistRepository, SocialQueryPort};
|
|
||||||
|
|
||||||
use crate::config::AppConfig;
|
use crate::config::AppConfig;
|
||||||
|
|
||||||
@@ -30,9 +29,7 @@ pub struct Repositories {
|
|||||||
pub search_port: Arc<dyn SearchPort>,
|
pub search_port: Arc<dyn SearchPort>,
|
||||||
pub search_command: Arc<dyn SearchCommand>,
|
pub search_command: Arc<dyn SearchCommand>,
|
||||||
pub profile_fields: Arc<dyn UserProfileFieldsRepository>,
|
pub profile_fields: Arc<dyn UserProfileFieldsRepository>,
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
pub remote_watchlist: Arc<dyn RemoteWatchlistRepository>,
|
pub remote_watchlist: Arc<dyn RemoteWatchlistRepository>,
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
pub social_query: Arc<dyn SocialQueryPort>,
|
pub social_query: Arc<dyn SocialQueryPort>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,44 +28,39 @@ pub async fn execute(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn build_following_filter(
|
async fn build_following_filter(
|
||||||
_ctx: &AppContext,
|
ctx: &AppContext,
|
||||||
query: &GetActivityFeedQuery,
|
query: &GetActivityFeedQuery,
|
||||||
) -> Option<FollowingFilter> {
|
) -> Option<FollowingFilter> {
|
||||||
#[cfg(not(feature = "federation"))]
|
if !query.filter_following {
|
||||||
{
|
|
||||||
let _ = query;
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
#[cfg(feature = "federation")]
|
let viewer_id = query.viewer_user_id?;
|
||||||
{
|
let urls = ctx
|
||||||
if !query.filter_following {
|
.repos
|
||||||
return None;
|
.social_query
|
||||||
}
|
.get_accepted_following_urls(viewer_id)
|
||||||
let viewer_id = match query.viewer_user_id {
|
.await
|
||||||
Some(id) => id,
|
.unwrap_or_default();
|
||||||
None => return None,
|
if urls.is_empty() {
|
||||||
};
|
return Some(FollowingFilter {
|
||||||
let urls = _ctx
|
local_user_ids: vec![viewer_id],
|
||||||
.repos
|
remote_actor_urls: vec![],
|
||||||
.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 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 auth;
|
||||||
pub mod diary;
|
pub mod diary;
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
pub mod federation;
|
|
||||||
pub mod import;
|
pub mod import;
|
||||||
pub mod integrations;
|
pub mod integrations;
|
||||||
pub mod movies;
|
pub mod movies;
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[cfg(feature = "federation")]
|
use domain::testing::{NoopRemoteWatchlistRepository, NoopSocialQueryPort};
|
||||||
use domain::testing::PanicRemoteWatchlistRepository;
|
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
use domain::testing::PanicSocialQueryPort;
|
|
||||||
use domain::{
|
use domain::{
|
||||||
ports::{
|
ports::{
|
||||||
AuthService, DiaryExporter, DiaryRepository, DocumentParser, EventPublisher, ImageStorage,
|
AuthService, DiaryExporter, DiaryRepository, DocumentParser, EventPublisher, ImageStorage,
|
||||||
@@ -145,10 +142,8 @@ impl TestContextBuilder {
|
|||||||
person_query: self.person_query,
|
person_query: self.person_query,
|
||||||
search_port: self.search_port,
|
search_port: self.search_port,
|
||||||
search_command: self.search_command,
|
search_command: self.search_command,
|
||||||
#[cfg(feature = "federation")]
|
remote_watchlist: Arc::new(NoopRemoteWatchlistRepository),
|
||||||
remote_watchlist: Arc::new(PanicRemoteWatchlistRepository),
|
social_query: Arc::new(NoopSocialQueryPort),
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
social_query: Arc::new(PanicSocialQueryPort),
|
|
||||||
},
|
},
|
||||||
services: Services {
|
services: Services {
|
||||||
auth: self.auth_service,
|
auth: self.auth_service,
|
||||||
|
|||||||
@@ -76,47 +76,40 @@ pub async fn execute(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn load_social_counts(
|
async fn load_social_counts(
|
||||||
_ctx: &AppContext,
|
ctx: &AppContext,
|
||||||
_user_id: uuid::Uuid,
|
user_id: uuid::Uuid,
|
||||||
_is_own_profile: bool,
|
is_own_profile: bool,
|
||||||
) -> (usize, usize, Vec<PendingFollowerView>) {
|
) -> (usize, usize, Vec<PendingFollowerView>) {
|
||||||
#[cfg(not(feature = "federation"))]
|
if !is_own_profile {
|
||||||
{
|
return (0, 0, vec![]);
|
||||||
(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)
|
|
||||||
}
|
}
|
||||||
|
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 {
|
fn feed_sort_to_direction(sort_by: FeedSortBy) -> SortDirection {
|
||||||
|
|||||||
@@ -10,16 +10,10 @@ pub async fn execute(
|
|||||||
ctx: &AppContext,
|
ctx: &AppContext,
|
||||||
_query: GetUsersQuery,
|
_query: GetUsersQuery,
|
||||||
) -> Result<UsersListData, DomainError> {
|
) -> Result<UsersListData, DomainError> {
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
let (users_result, actors_result) = tokio::join!(
|
let (users_result, actors_result) = tokio::join!(
|
||||||
ctx.repos.user.list_with_stats(),
|
ctx.repos.user.list_with_stats(),
|
||||||
ctx.repos.social_query.list_all_followed_remote_actors()
|
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 {
|
Ok(UsersListData {
|
||||||
users: users_result?,
|
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(
|
async fn load_remote_watchlist(
|
||||||
ctx: &AppContext,
|
ctx: &AppContext,
|
||||||
user_id: uuid::Uuid,
|
user_id: uuid::Uuid,
|
||||||
) -> Result<WatchlistPageResult, DomainError> {
|
) -> 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
|
.await
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let len = remote_entries.len() as u32;
|
let len = remote_entries.len() as u32;
|
||||||
|
|||||||
@@ -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;
|
pub struct PanicProfileFieldsRepo;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
@@ -187,8 +187,12 @@ async fn wire_dependencies() -> anyhow::Result<(AppState, axum::Router)> {
|
|||||||
profile_fields: db.profile_fields,
|
profile_fields: db.profile_fields,
|
||||||
#[cfg(feature = "federation")]
|
#[cfg(feature = "federation")]
|
||||||
remote_watchlist: remote_watchlist_repo,
|
remote_watchlist: remote_watchlist_repo,
|
||||||
|
#[cfg(not(feature = "federation"))]
|
||||||
|
remote_watchlist: Arc::new(domain::testing::NoopRemoteWatchlistRepository),
|
||||||
#[cfg(feature = "federation")]
|
#[cfg(feature = "federation")]
|
||||||
social_query: social_query.clone(),
|
social_query: social_query.clone(),
|
||||||
|
#[cfg(not(feature = "federation"))]
|
||||||
|
social_query: Arc::new(domain::testing::NoopSocialQueryPort),
|
||||||
},
|
},
|
||||||
services: Services {
|
services: Services {
|
||||||
auth: auth_service,
|
auth: auth_service,
|
||||||
|
|||||||
@@ -591,9 +591,7 @@ pub fn make_test_state(auth_service: Arc<dyn AuthService>) -> crate::state::AppS
|
|||||||
person_query: Arc::clone(&repo) as _,
|
person_query: Arc::clone(&repo) as _,
|
||||||
search_port: Arc::clone(&repo) as _,
|
search_port: Arc::clone(&repo) as _,
|
||||||
search_command: Arc::clone(&repo) as _,
|
search_command: Arc::clone(&repo) as _,
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
remote_watchlist: Arc::clone(&repo) as _,
|
remote_watchlist: Arc::clone(&repo) as _,
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
social_query: Arc::clone(&repo) as _,
|
social_query: Arc::clone(&repo) as _,
|
||||||
},
|
},
|
||||||
services: Services {
|
services: Services {
|
||||||
|
|||||||
@@ -413,9 +413,7 @@ async fn test_app() -> Router {
|
|||||||
person_query: Arc::new(PanicPersonQuery),
|
person_query: Arc::new(PanicPersonQuery),
|
||||||
search_port: Arc::new(PanicSearchPort),
|
search_port: Arc::new(PanicSearchPort),
|
||||||
search_command: Arc::new(PanicSearchCommand),
|
search_command: Arc::new(PanicSearchCommand),
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
remote_watchlist: Arc::new(PanicRemoteWatchlist),
|
remote_watchlist: Arc::new(PanicRemoteWatchlist),
|
||||||
#[cfg(feature = "federation")]
|
|
||||||
social_query: Arc::new(PanicSocialQuery),
|
social_query: Arc::new(PanicSocialQuery),
|
||||||
},
|
},
|
||||||
services: Services {
|
services: Services {
|
||||||
|
|||||||
@@ -86,8 +86,12 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
search_command: db.search_command,
|
search_command: db.search_command,
|
||||||
#[cfg(feature = "federation")]
|
#[cfg(feature = "federation")]
|
||||||
remote_watchlist: fed_remote_watchlist_repo.clone(),
|
remote_watchlist: fed_remote_watchlist_repo.clone(),
|
||||||
|
#[cfg(not(feature = "federation"))]
|
||||||
|
remote_watchlist: Arc::new(domain::testing::NoopRemoteWatchlistRepository),
|
||||||
#[cfg(feature = "federation")]
|
#[cfg(feature = "federation")]
|
||||||
social_query: fed_social_query,
|
social_query: fed_social_query,
|
||||||
|
#[cfg(not(feature = "federation"))]
|
||||||
|
social_query: Arc::new(domain::testing::NoopSocialQueryPort),
|
||||||
},
|
},
|
||||||
services: Services {
|
services: Services {
|
||||||
auth: auth_service,
|
auth: auth_service,
|
||||||
|
|||||||
Reference in New Issue
Block a user