From 171cfe43737543b1a7eb91c8339fbbcf580206c4 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Thu, 14 May 2026 18:03:16 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20follow/block=20handlers=20accept=20usern?= =?UTF-8?q?ame=20string=20=E2=80=94=20was=20parsing=20as=20UUID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/presentation/src/handlers/social.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/presentation/src/handlers/social.rs b/crates/presentation/src/handlers/social.rs index 3946eb0..5284d1c 100644 --- a/crates/presentation/src/handlers/social.rs +++ b/crates/presentation/src/handlers/social.rs @@ -50,36 +50,40 @@ pub async fn delete_boost( pub async fn post_follow( State(s): State, AuthUser(uid): AuthUser, - Path(target): Path, + Path(username): Path, ) -> Result { - 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) } #[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( State(s): State, AuthUser(uid): AuthUser, - Path(target): Path, + Path(username): Path, ) -> Result { - 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) } #[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( State(s): State, AuthUser(uid): AuthUser, - Path(target): Path, + Path(username): Path, ) -> Result { - 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) } #[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( State(s): State, AuthUser(uid): AuthUser, - Path(target): Path, + Path(username): Path, ) -> Result { - 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) } #[utoipa::path(put, path = "/users/me/top-friends", request_body = SetTopFriendsRequest, responses((status = 204, description = "Top friends updated")), security(("bearer_auth" = [])))]