refactor: Feed uses SocialIdentity matching, deps From impl, remove get_accepted_following_urls
Feed builds FollowingFilter by matching SocialIdentity::Local/Remote instead of URL-prefix heuristic. Removed get_accepted_following_urls from SocialQuery (no longer needed). Added From<&AppState> for deps structs — 20 construction sites collapsed to one-liners.
This commit is contained in:
@@ -243,15 +243,4 @@ impl SocialQuery for CompositeSocialAdapter {
|
|||||||
Ok(following.iter().any(|a| a.identity == *target))
|
Ok(following.iter().any(|a| a.identity == *target))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_accepted_following_urls(
|
|
||||||
&self,
|
|
||||||
user_id: &UserId,
|
|
||||||
) -> Result<Vec<String>, DomainError> {
|
|
||||||
let actors = self
|
|
||||||
.ap_service
|
|
||||||
.get_following(user_id.value())
|
|
||||||
.await
|
|
||||||
.map_err(ap_err)?;
|
|
||||||
Ok(actors.into_iter().map(|a| a.url).collect())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use domain::{
|
|||||||
FeedEntry,
|
FeedEntry,
|
||||||
collections::{PageParams, Paginated},
|
collections::{PageParams, Paginated},
|
||||||
},
|
},
|
||||||
value_objects::UserId,
|
value_objects::{SocialIdentity, UserId},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
@@ -36,28 +36,24 @@ async fn build_following_filter(
|
|||||||
}
|
}
|
||||||
let viewer_id = query.viewer_user_id?;
|
let viewer_id = query.viewer_user_id?;
|
||||||
let viewer = UserId::from_uuid(viewer_id);
|
let viewer = UserId::from_uuid(viewer_id);
|
||||||
let urls = deps
|
let actors = deps
|
||||||
.social_query
|
.social_query
|
||||||
.get_accepted_following_urls(&viewer)
|
.get_following(&viewer)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
if urls.is_empty() {
|
if actors.is_empty() {
|
||||||
return Some(FollowingFilter {
|
return Some(FollowingFilter {
|
||||||
local_user_ids: vec![viewer_id],
|
local_user_ids: vec![viewer_id],
|
||||||
remote_actor_urls: vec![],
|
remote_actor_urls: vec![],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let base_url = &deps.config.base_url;
|
|
||||||
let mut local_ids = vec![viewer_id];
|
let mut local_ids = vec![viewer_id];
|
||||||
let mut remote_urls = Vec::new();
|
let mut remote_urls = Vec::new();
|
||||||
for url in urls {
|
for actor in actors {
|
||||||
if let Some(suffix) = url.strip_prefix(&format!("{}/users/", base_url))
|
match actor.identity {
|
||||||
&& let Ok(parsed_id) = uuid::Uuid::parse_str(suffix)
|
SocialIdentity::Local(uid) => local_ids.push(uid.value()),
|
||||||
{
|
SocialIdentity::Remote { actor_url } => remote_urls.push(actor_url),
|
||||||
local_ids.push(parsed_id);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
remote_urls.push(url);
|
|
||||||
}
|
}
|
||||||
Some(FollowingFilter {
|
Some(FollowingFilter {
|
||||||
local_user_ids: local_ids,
|
local_user_ids: local_ids,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use domain::errors::DomainError;
|
use domain::errors::DomainError;
|
||||||
use domain::testing::InMemorySocialRepository;
|
use domain::testing::InMemorySocialRepository;
|
||||||
use domain::value_objects::SocialActor;
|
use domain::value_objects::{SocialActor, SocialIdentity, UserId};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::AppConfig, diary::deps::GetActivityFeedDeps, diary::get_activity_feed,
|
config::AppConfig, diary::deps::GetActivityFeedDeps, diary::get_activity_feed,
|
||||||
@@ -63,72 +63,59 @@ async fn returns_feed_with_following_filter() {
|
|||||||
assert!(result.items.is_empty());
|
assert!(result.items.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FakeSocialWithFollowing(Vec<String>);
|
struct FakeSocialWithFollowing(Vec<SocialActor>);
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl domain::ports::SocialQuery for FakeSocialWithFollowing {
|
impl domain::ports::SocialQuery for FakeSocialWithFollowing {
|
||||||
async fn get_following(
|
async fn get_following(
|
||||||
&self,
|
&self,
|
||||||
_: &domain::value_objects::UserId,
|
_: &UserId,
|
||||||
) -> Result<Vec<SocialActor>, DomainError> {
|
) -> Result<Vec<SocialActor>, DomainError> {
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
async fn get_followers(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<Vec<SocialActor>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
async fn get_pending_followers(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<Vec<SocialActor>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
async fn count_following(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<usize, DomainError> {
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
async fn count_followers(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<usize, DomainError> {
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
async fn get_blocked(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<Vec<SocialActor>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
async fn is_following(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
_: &domain::value_objects::SocialIdentity,
|
|
||||||
) -> Result<bool, DomainError> {
|
|
||||||
Ok(false)
|
|
||||||
}
|
|
||||||
async fn get_accepted_following_urls(
|
|
||||||
&self,
|
|
||||||
_: &domain::value_objects::UserId,
|
|
||||||
) -> Result<Vec<String>, DomainError> {
|
|
||||||
Ok(self.0.clone())
|
Ok(self.0.clone())
|
||||||
}
|
}
|
||||||
|
async fn get_followers(&self, _: &UserId) -> Result<Vec<SocialActor>, DomainError> {
|
||||||
|
Ok(vec![])
|
||||||
|
}
|
||||||
|
async fn get_pending_followers(&self, _: &UserId) -> Result<Vec<SocialActor>, DomainError> {
|
||||||
|
Ok(vec![])
|
||||||
|
}
|
||||||
|
async fn count_following(&self, _: &UserId) -> Result<usize, DomainError> {
|
||||||
|
Ok(0)
|
||||||
|
}
|
||||||
|
async fn count_followers(&self, _: &UserId) -> Result<usize, DomainError> {
|
||||||
|
Ok(0)
|
||||||
|
}
|
||||||
|
async fn get_blocked(&self, _: &UserId) -> Result<Vec<SocialActor>, DomainError> {
|
||||||
|
Ok(vec![])
|
||||||
|
}
|
||||||
|
async fn is_following(&self, _: &UserId, _: &SocialIdentity) -> Result<bool, DomainError> {
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn following_filter_parses_local_and_remote_urls() {
|
async fn following_filter_separates_local_and_remote() {
|
||||||
let viewer = uuid::Uuid::new_v4();
|
let viewer = uuid::Uuid::new_v4();
|
||||||
let local_friend = uuid::Uuid::new_v4();
|
let local_friend = uuid::Uuid::new_v4();
|
||||||
|
|
||||||
let following_urls = vec![
|
let following = vec![
|
||||||
format!("http://localhost:3000/users/{}", local_friend),
|
SocialActor {
|
||||||
"https://remote.example/actor/1".to_string(),
|
identity: SocialIdentity::Local(UserId::from_uuid(local_friend)),
|
||||||
|
handle: "friend".into(),
|
||||||
|
display_name: None,
|
||||||
|
avatar_url: None,
|
||||||
|
},
|
||||||
|
SocialActor {
|
||||||
|
identity: SocialIdentity::Remote {
|
||||||
|
actor_url: "https://remote.example/actor/1".into(),
|
||||||
|
},
|
||||||
|
handle: "@alice@remote.example".into(),
|
||||||
|
display_name: None,
|
||||||
|
avatar_url: None,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let social = Arc::new(FakeSocialWithFollowing(following_urls));
|
let social = Arc::new(FakeSocialWithFollowing(following));
|
||||||
|
|
||||||
let deps = GetActivityFeedDeps {
|
let deps = GetActivityFeedDeps {
|
||||||
diary: domain::testing::FakeDiaryQuery::new() as _,
|
diary: domain::testing::FakeDiaryQuery::new() as _,
|
||||||
|
|||||||
@@ -91,9 +91,6 @@ impl super::SocialQuery for NoopSocialQuery {
|
|||||||
async fn is_following(&self, _: &UserId, _: &SocialIdentity) -> Result<bool, DomainError> {
|
async fn is_following(&self, _: &UserId, _: &SocialIdentity) -> Result<bool, DomainError> {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
async fn get_accepted_following_urls(&self, _: &UserId) -> Result<Vec<String>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── NoopFederationAdminQuery ─────────────────────────────────────────────────
|
// ── NoopFederationAdminQuery ─────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -62,10 +62,6 @@ pub trait SocialQuery: Send + Sync {
|
|||||||
target: &SocialIdentity,
|
target: &SocialIdentity,
|
||||||
) -> Result<bool, DomainError>;
|
) -> Result<bool, DomainError>;
|
||||||
|
|
||||||
async fn get_accepted_following_urls(
|
|
||||||
&self,
|
|
||||||
user_id: &UserId,
|
|
||||||
) -> Result<Vec<String>, DomainError>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
@@ -1106,10 +1106,4 @@ impl SocialQuery for InMemorySocialRepository {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_accepted_following_urls(
|
|
||||||
&self,
|
|
||||||
_user_id: &UserId,
|
|
||||||
) -> Result<Vec<String>, DomainError> {
|
|
||||||
Ok(vec![])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,24 @@ use template_askama::{
|
|||||||
|
|
||||||
use super::helpers::{build_page_context, encode_error};
|
use super::helpers::{build_page_context, encode_error};
|
||||||
|
|
||||||
|
impl From<&AppState> for SocialCommandDeps {
|
||||||
|
fn from(state: &AppState) -> Self {
|
||||||
|
Self {
|
||||||
|
social_command: state.app_ctx.repos.social_command.clone(),
|
||||||
|
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
||||||
|
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&AppState> for SocialQueryDeps {
|
||||||
|
fn from(state: &AppState) -> Self {
|
||||||
|
Self {
|
||||||
|
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn ap_to_domain(e: anyhow::Error) -> domain::errors::DomainError {
|
fn ap_to_domain(e: anyhow::Error) -> domain::errors::DomainError {
|
||||||
tracing::error!("ActivityPub error: {:?}", e);
|
tracing::error!("ActivityPub error: {:?}", e);
|
||||||
domain::errors::DomainError::InfrastructureError(e.to_string())
|
domain::errors::DomainError::InfrastructureError(e.to_string())
|
||||||
@@ -166,11 +184,7 @@ pub async fn block_actor_api(
|
|||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
axum::Json(body): axum::Json<ActorUrlRequest>,
|
axum::Json(body): axum::Json<ActorUrlRequest>,
|
||||||
) -> Result<impl IntoResponse, ApiError> {
|
) -> Result<impl IntoResponse, ApiError> {
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
application::social::execute::execute_command(
|
application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::Block {
|
application::social::commands::SocialCmd::Block {
|
||||||
@@ -198,11 +212,7 @@ pub async fn unblock_actor_api(
|
|||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
axum::Json(body): axum::Json<ActorUrlRequest>,
|
axum::Json(body): axum::Json<ActorUrlRequest>,
|
||||||
) -> Result<impl IntoResponse, ApiError> {
|
) -> Result<impl IntoResponse, ApiError> {
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
application::social::execute::execute_command(
|
application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::Unblock {
|
application::social::commands::SocialCmd::Unblock {
|
||||||
@@ -228,9 +238,7 @@ pub async fn get_blocked_actors_api(
|
|||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
) -> Result<Json<Vec<BlockedActorResponse>>, ApiError> {
|
) -> Result<Json<Vec<BlockedActorResponse>>, ApiError> {
|
||||||
let deps = SocialQueryDeps {
|
let deps = SocialQueryDeps::from(&state);
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
};
|
|
||||||
let identities = application::social::execute::execute_query(
|
let identities = application::social::execute::execute_query(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::queries::SocialQry::GetBlocked {
|
application::social::queries::SocialQry::GetBlocked {
|
||||||
@@ -258,9 +266,7 @@ pub async fn get_following(
|
|||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
) -> Result<Json<ActorListResponse>, ApiError> {
|
) -> Result<Json<ActorListResponse>, ApiError> {
|
||||||
let deps = SocialQueryDeps {
|
let deps = SocialQueryDeps::from(&state);
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
};
|
|
||||||
let identities = application::social::execute::execute_query(
|
let identities = application::social::execute::execute_query(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::queries::SocialQry::GetFollowing {
|
application::social::queries::SocialQry::GetFollowing {
|
||||||
@@ -285,9 +291,7 @@ pub async fn get_followers(
|
|||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
) -> Result<Json<ActorListResponse>, ApiError> {
|
) -> Result<Json<ActorListResponse>, ApiError> {
|
||||||
let deps = SocialQueryDeps {
|
let deps = SocialQueryDeps::from(&state);
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
};
|
|
||||||
let identities = application::social::execute::execute_query(
|
let identities = application::social::execute::execute_query(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::queries::SocialQry::GetFollowers {
|
application::social::queries::SocialQry::GetFollowers {
|
||||||
@@ -305,9 +309,7 @@ pub async fn get_user_following(
|
|||||||
_user: AuthenticatedUser,
|
_user: AuthenticatedUser,
|
||||||
Path(user_id): Path<Uuid>,
|
Path(user_id): Path<Uuid>,
|
||||||
) -> Result<Json<ActorListResponse>, ApiError> {
|
) -> Result<Json<ActorListResponse>, ApiError> {
|
||||||
let deps = SocialQueryDeps {
|
let deps = SocialQueryDeps::from(&state);
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
};
|
|
||||||
let identities = application::social::execute::execute_query(
|
let identities = application::social::execute::execute_query(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::queries::SocialQry::GetFollowing { user_id },
|
application::social::queries::SocialQry::GetFollowing { user_id },
|
||||||
@@ -323,9 +325,7 @@ pub async fn get_user_followers(
|
|||||||
_user: AuthenticatedUser,
|
_user: AuthenticatedUser,
|
||||||
Path(user_id): Path<Uuid>,
|
Path(user_id): Path<Uuid>,
|
||||||
) -> Result<Json<ActorListResponse>, ApiError> {
|
) -> Result<Json<ActorListResponse>, ApiError> {
|
||||||
let deps = SocialQueryDeps {
|
let deps = SocialQueryDeps::from(&state);
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
};
|
|
||||||
let identities = application::social::execute::execute_query(
|
let identities = application::social::execute::execute_query(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::queries::SocialQry::GetFollowers { user_id },
|
application::social::queries::SocialQry::GetFollowers { user_id },
|
||||||
@@ -350,11 +350,7 @@ pub async fn follow(
|
|||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
Json(body): Json<FollowRequest>,
|
Json(body): Json<FollowRequest>,
|
||||||
) -> Result<impl IntoResponse, ApiError> {
|
) -> Result<impl IntoResponse, ApiError> {
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
application::social::execute::execute_command(
|
application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::Follow {
|
application::social::commands::SocialCmd::Follow {
|
||||||
@@ -380,11 +376,7 @@ pub async fn unfollow(
|
|||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
Json(body): Json<ActorUrlRequest>,
|
Json(body): Json<ActorUrlRequest>,
|
||||||
) -> Result<impl IntoResponse, ApiError> {
|
) -> Result<impl IntoResponse, ApiError> {
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
application::social::execute::execute_command(
|
application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::Unfollow {
|
application::social::commands::SocialCmd::Unfollow {
|
||||||
@@ -412,11 +404,7 @@ pub async fn accept_follower(
|
|||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
Json(body): Json<ActorUrlRequest>,
|
Json(body): Json<ActorUrlRequest>,
|
||||||
) -> Result<impl IntoResponse, ApiError> {
|
) -> Result<impl IntoResponse, ApiError> {
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
application::social::execute::execute_command(
|
application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::AcceptFollow {
|
application::social::commands::SocialCmd::AcceptFollow {
|
||||||
@@ -444,11 +432,7 @@ pub async fn reject_follower(
|
|||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
Json(body): Json<ActorUrlRequest>,
|
Json(body): Json<ActorUrlRequest>,
|
||||||
) -> Result<impl IntoResponse, ApiError> {
|
) -> Result<impl IntoResponse, ApiError> {
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
application::social::execute::execute_command(
|
application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::RejectFollow {
|
application::social::commands::SocialCmd::RejectFollow {
|
||||||
@@ -476,11 +460,7 @@ pub async fn remove_follower(
|
|||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
Json(body): Json<ActorUrlRequest>,
|
Json(body): Json<ActorUrlRequest>,
|
||||||
) -> Result<impl IntoResponse, ApiError> {
|
) -> Result<impl IntoResponse, ApiError> {
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
application::social::execute::execute_command(
|
application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::RemoveFollower {
|
application::social::commands::SocialCmd::RemoveFollower {
|
||||||
@@ -506,9 +486,7 @@ pub async fn get_pending_followers(
|
|||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
user: AuthenticatedUser,
|
user: AuthenticatedUser,
|
||||||
) -> Result<Json<ActorListResponse>, ApiError> {
|
) -> Result<Json<ActorListResponse>, ApiError> {
|
||||||
let deps = SocialQueryDeps {
|
let deps = SocialQueryDeps::from(&state);
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
};
|
|
||||||
let identities = application::social::execute::execute_query(
|
let identities = application::social::execute::execute_query(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::queries::SocialQry::GetPending {
|
application::social::queries::SocialQry::GetPending {
|
||||||
@@ -543,11 +521,7 @@ pub async fn follow_remote_user(
|
|||||||
.unwrap_or(&format!("/users/{}", profile_user_uuid))
|
.unwrap_or(&format!("/users/{}", profile_user_uuid))
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_command(
|
match application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::Follow {
|
application::social::commands::SocialCmd::Follow {
|
||||||
@@ -584,11 +558,7 @@ pub async fn unfollow_remote_user(
|
|||||||
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
||||||
return StatusCode::FORBIDDEN.into_response();
|
return StatusCode::FORBIDDEN.into_response();
|
||||||
}
|
}
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_command(
|
match application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::Unfollow {
|
application::social::commands::SocialCmd::Unfollow {
|
||||||
@@ -627,11 +597,7 @@ pub async fn accept_follower_html(
|
|||||||
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
||||||
return StatusCode::FORBIDDEN.into_response();
|
return StatusCode::FORBIDDEN.into_response();
|
||||||
}
|
}
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_command(
|
match application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::AcceptFollow {
|
application::social::commands::SocialCmd::AcceptFollow {
|
||||||
@@ -664,11 +630,7 @@ pub async fn reject_follower_html(
|
|||||||
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
||||||
return StatusCode::FORBIDDEN.into_response();
|
return StatusCode::FORBIDDEN.into_response();
|
||||||
}
|
}
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_command(
|
match application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::RejectFollow {
|
application::social::commands::SocialCmd::RejectFollow {
|
||||||
@@ -770,9 +732,7 @@ pub async fn get_following_page(
|
|||||||
"{}/users/{}/following-list",
|
"{}/users/{}/following-list",
|
||||||
state.app_ctx.config.base_url, profile_user_uuid
|
state.app_ctx.config.base_url, profile_user_uuid
|
||||||
);
|
);
|
||||||
let deps = SocialQueryDeps {
|
let deps = SocialQueryDeps::from(&state);
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_query(
|
match application::social::execute::execute_query(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::queries::SocialQry::GetFollowing {
|
application::social::queries::SocialQry::GetFollowing {
|
||||||
@@ -821,9 +781,7 @@ pub async fn get_followers_page(
|
|||||||
"{}/users/{}/followers-list",
|
"{}/users/{}/followers-list",
|
||||||
state.app_ctx.config.base_url, profile_user_uuid
|
state.app_ctx.config.base_url, profile_user_uuid
|
||||||
);
|
);
|
||||||
let deps = SocialQueryDeps {
|
let deps = SocialQueryDeps::from(&state);
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_query(
|
match application::social::execute::execute_query(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::queries::SocialQry::GetFollowers {
|
application::social::queries::SocialQry::GetFollowers {
|
||||||
@@ -869,11 +827,7 @@ pub async fn remove_follower_html(
|
|||||||
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
||||||
return StatusCode::FORBIDDEN.into_response();
|
return StatusCode::FORBIDDEN.into_response();
|
||||||
}
|
}
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_command(
|
match application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::RemoveFollower {
|
application::social::commands::SocialCmd::RemoveFollower {
|
||||||
@@ -997,9 +951,7 @@ pub async fn get_blocked_actors_page(
|
|||||||
let mut ctx = build_page_context(&state, Some(user_id.clone()), csrf.0).await;
|
let mut ctx = build_page_context(&state, Some(user_id.clone()), csrf.0).await;
|
||||||
ctx.page_title = "Blocked Users — Movies Diary".to_string();
|
ctx.page_title = "Blocked Users — Movies Diary".to_string();
|
||||||
ctx.canonical_url = format!("{}/social/blocked", state.app_ctx.config.base_url);
|
ctx.canonical_url = format!("{}/social/blocked", state.app_ctx.config.base_url);
|
||||||
let deps = SocialQueryDeps {
|
let deps = SocialQueryDeps::from(&state);
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_query(
|
match application::social::execute::execute_query(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::queries::SocialQry::GetBlocked {
|
application::social::queries::SocialQry::GetBlocked {
|
||||||
@@ -1044,11 +996,7 @@ pub async fn post_block_actor_html(
|
|||||||
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
||||||
return StatusCode::FORBIDDEN.into_response();
|
return StatusCode::FORBIDDEN.into_response();
|
||||||
}
|
}
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_command(
|
match application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::Block {
|
application::social::commands::SocialCmd::Block {
|
||||||
@@ -1077,11 +1025,7 @@ pub async fn post_unblock_actor(
|
|||||||
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
if crate::csrf::mismatch(&csrf, &form.csrf_token) {
|
||||||
return StatusCode::FORBIDDEN.into_response();
|
return StatusCode::FORBIDDEN.into_response();
|
||||||
}
|
}
|
||||||
let deps = SocialCommandDeps {
|
let deps = SocialCommandDeps::from(&state);
|
||||||
social_command: state.app_ctx.repos.social_command.clone(),
|
|
||||||
social_query: state.app_ctx.repos.social_query_unified.clone(),
|
|
||||||
event_publisher: state.app_ctx.services.event_publisher.clone(),
|
|
||||||
};
|
|
||||||
match application::social::execute::execute_command(
|
match application::social::execute::execute_command(
|
||||||
&deps,
|
&deps,
|
||||||
application::social::commands::SocialCmd::Unblock {
|
application::social::commands::SocialCmd::Unblock {
|
||||||
|
|||||||
Reference in New Issue
Block a user