fix: follow/block handlers accept username string — was parsing as UUID
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m38s
test / unit (pull_request) Successful in 16m13s
test / integration (pull_request) Failing after 17m31s

This commit is contained in:
2026-05-14 18:03:16 +02:00
parent 24bfda8458
commit 171cfe4373

View File

@@ -50,36 +50,40 @@ pub async fn delete_boost(
pub async fn post_follow( pub async fn post_follow(
State(s): State<AppState>, State(s): State<AppState>,
AuthUser(uid): AuthUser, AuthUser(uid): AuthUser,
Path(target): Path<Uuid>, Path(username): Path<String>,
) -> Result<StatusCode, ApiError> { ) -> Result<StatusCode, ApiError> {
follow_user(&*s.follows, &*s.events, &uid, &UserId::from_uuid(target)).await?; let target = get_user_by_username(&*s.users, &username).await?;
follow_user(&*s.follows, &*s.events, &uid, &target.id).await?;
Ok(StatusCode::NO_CONTENT) Ok(StatusCode::NO_CONTENT)
} }
#[utoipa::path(delete, path = "/users/{id}/follow", params(("id" = uuid::Uuid, Path, description = "User ID")), responses((status = 204, description = "Unfollowed")), security(("bearer_auth" = [])))] #[utoipa::path(delete, path = "/users/{id}/follow", params(("id" = uuid::Uuid, Path, description = "User ID")), responses((status = 204, description = "Unfollowed")), security(("bearer_auth" = [])))]
pub async fn delete_follow( pub async fn delete_follow(
State(s): State<AppState>, State(s): State<AppState>,
AuthUser(uid): AuthUser, AuthUser(uid): AuthUser,
Path(target): Path<Uuid>, Path(username): Path<String>,
) -> Result<StatusCode, ApiError> { ) -> Result<StatusCode, ApiError> {
unfollow_user(&*s.follows, &*s.events, &uid, &UserId::from_uuid(target)).await?; let target = get_user_by_username(&*s.users, &username).await?;
unfollow_user(&*s.follows, &*s.events, &uid, &target.id).await?;
Ok(StatusCode::NO_CONTENT) Ok(StatusCode::NO_CONTENT)
} }
#[utoipa::path(post, path = "/users/{id}/block", params(("id" = uuid::Uuid, Path, description = "User ID")), responses((status = 204, description = "Blocked")), security(("bearer_auth" = [])))] #[utoipa::path(post, path = "/users/{id}/block", params(("id" = uuid::Uuid, Path, description = "User ID")), responses((status = 204, description = "Blocked")), security(("bearer_auth" = [])))]
pub async fn post_block( pub async fn post_block(
State(s): State<AppState>, State(s): State<AppState>,
AuthUser(uid): AuthUser, AuthUser(uid): AuthUser,
Path(target): Path<Uuid>, Path(username): Path<String>,
) -> Result<StatusCode, ApiError> { ) -> Result<StatusCode, ApiError> {
block_user(&*s.blocks, &*s.events, &uid, &UserId::from_uuid(target)).await?; let target = get_user_by_username(&*s.users, &username).await?;
block_user(&*s.blocks, &*s.events, &uid, &target.id).await?;
Ok(StatusCode::NO_CONTENT) Ok(StatusCode::NO_CONTENT)
} }
#[utoipa::path(delete, path = "/users/{id}/block", params(("id" = uuid::Uuid, Path, description = "User ID")), responses((status = 204, description = "Unblocked")), security(("bearer_auth" = [])))] #[utoipa::path(delete, path = "/users/{id}/block", params(("id" = uuid::Uuid, Path, description = "User ID")), responses((status = 204, description = "Unblocked")), security(("bearer_auth" = [])))]
pub async fn delete_block( pub async fn delete_block(
State(s): State<AppState>, State(s): State<AppState>,
AuthUser(uid): AuthUser, AuthUser(uid): AuthUser,
Path(target): Path<Uuid>, Path(username): Path<String>,
) -> Result<StatusCode, ApiError> { ) -> Result<StatusCode, ApiError> {
unblock_user(&*s.blocks, &*s.events, &uid, &UserId::from_uuid(target)).await?; let target = get_user_by_username(&*s.users, &username).await?;
unblock_user(&*s.blocks, &*s.events, &uid, &target.id).await?;
Ok(StatusCode::NO_CONTENT) Ok(StatusCode::NO_CONTENT)
} }
#[utoipa::path(put, path = "/users/me/top-friends", request_body = SetTopFriendsRequest, responses((status = 204, description = "Top friends updated")), security(("bearer_auth" = [])))] #[utoipa::path(put, path = "/users/me/top-friends", request_body = SetTopFriendsRequest, responses((status = 204, description = "Top friends updated")), security(("bearer_auth" = [])))]