Skip to content
Clone
a06673b
27 lines 808 B Rust
use axum::Json;
use axum::extract::{Path, State};
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::UserResult;
use crate::features::UserService;
#[utoipa::path(
post,
path = "/user/me/blocks/{uid}",
tag = "user",
params(("uid" = Uuid, Path, description = "Target user identifier.")),
responses(
(status = 200, description = "Block succeeded (idempotent; also unfollows both directions)."),
(status = 404, description = "Target user not found."),
),
security(("bearer_auth" = [])),
)]
pub(crate) async fn handler(
State(svc): State<UserService>,
AuthUser { claims }: AuthUser,
Path(uid): Path<Uuid>,
) -> UserResult<Json<serde_json::Value>> {
svc.block_user(claims.sub, uid).await?;
Ok(Json(serde_json::json!({ "ok": true })))
}