refactor: move UUID/username routing to application use case — fix handler boundary leak
This commit is contained in:
@@ -23,6 +23,21 @@ pub async fn get_user_by_username(
|
||||
.ok_or(DomainError::NotFound)
|
||||
}
|
||||
|
||||
/// Resolve a path segment that is either a UUID (AP actor URL) or a username.
|
||||
pub async fn get_user_by_id_or_username(
|
||||
users: &dyn UserRepository,
|
||||
id_or_username: &str,
|
||||
) -> Result<User, DomainError> {
|
||||
if let Ok(uuid) = uuid::Uuid::parse_str(id_or_username) {
|
||||
users
|
||||
.find_by_id(&UserId::from_uuid(uuid))
|
||||
.await?
|
||||
.ok_or(DomainError::NotFound)
|
||||
} else {
|
||||
get_user_by_username(users, id_or_username).await
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn update_profile(
|
||||
users: &dyn UserRepository,
|
||||
user_id: &UserId,
|
||||
|
||||
Reference in New Issue
Block a user