feat: API endpoints for any user's following/followers

This commit is contained in:
2026-06-04 02:34:01 +02:00
parent dbc78a1ff4
commit c4908b7765
2 changed files with 52 additions and 0 deletions

View File

@@ -770,6 +770,50 @@ pub async fn get_followers(
}
}
#[cfg(feature = "federation")]
pub async fn get_user_following(
State(state): State<AppState>,
_user: AuthenticatedUser,
Path(user_id): Path<Uuid>,
) -> impl IntoResponse {
match state.ap_service.get_following(user_id).await {
Ok(actors) => Json(ActorListResponse {
actors: actors
.into_iter()
.map(|a| RemoteActorDto {
handle: a.handle,
display_name: a.display_name,
url: a.url,
})
.collect(),
})
.into_response(),
Err(e) => ap_err(e).into_response(),
}
}
#[cfg(feature = "federation")]
pub async fn get_user_followers(
State(state): State<AppState>,
_user: AuthenticatedUser,
Path(user_id): Path<Uuid>,
) -> impl IntoResponse {
match state.ap_service.get_accepted_followers(user_id).await {
Ok(actors) => Json(ActorListResponse {
actors: actors
.into_iter()
.map(|a| RemoteActorDto {
handle: a.handle,
display_name: a.display_name,
url: a.url,
})
.collect(),
})
.into_response(),
Err(e) => ap_err(e).into_response(),
}
}
#[cfg(feature = "federation")]
#[utoipa::path(
post, path = "/api/v1/social/follow",

View File

@@ -322,6 +322,14 @@ fn api_routes(rate_limit: u64) -> Router<AppState> {
)
.route("/users", routing::get(handlers::api::list_users))
.route("/users/{id}", routing::get(handlers::api::get_user_profile))
.route(
"/users/{id}/following",
routing::get(handlers::api::get_user_following),
)
.route(
"/users/{id}/followers",
routing::get(handlers::api::get_user_followers),
)
.route(
"/import/sessions",
routing::post(handlers::import::api_post_session),