a06673b
use axum::Json;
use axum::extract::{Path, State};
use jwt::extractor::AuthUser;
use serde::Deserialize;
use uuid::Uuid;
use crate::error::UserResult;
use crate::features::UserService;
#[derive(Debug, Deserialize)]
pub(crate) struct FollowPath {
pub uid: Uuid,
}
#[utoipa::path(
post,
path = "/user/users/{uid}/follow",
tag = "user",
params(("uid" = Uuid, Path, description = "Target user identifier.")),
responses(
(status = 200, description = "Follow succeeded (idempotent)."),
(status = 404, description = "Target user not found."),
),
security(("bearer_auth" = [])),
)]
pub(crate) async fn handler(
State(svc): State<UserService>,
AuthUser { claims }: AuthUser,
Path(FollowPath { uid }): Path<FollowPath>,
) -> UserResult<Json<serde_json::Value>> {
svc.follow_user(claims.sub, uid).await?;
Ok(Json(serde_json::json!({ "ok": true })))
}