refactor(manager-core): share resolve_app helper across handlers
apps_api.rs and app_members_api.rs each grew a near-identical local `resolve_app` that parses an id-or-slug param and translates None into their own AppNotFound variant. Promote the lookup half to `app_repo::resolve_app` (returns `Result<Option<AppLookup>, ...>`) and let callers handle the None → not-found mapping. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -454,16 +454,7 @@ async fn resolve_app(
|
||||
apps: &dyn AppRepository,
|
||||
ident: &str,
|
||||
) -> Result<crate::app_repo::AppLookup, AppsApiError> {
|
||||
if let Ok(uuid) = ident.parse::<Uuid>() {
|
||||
if let Some(app) = apps.get_by_id(AppId::from(uuid)).await? {
|
||||
return Ok(crate::app_repo::AppLookup {
|
||||
app,
|
||||
redirected: false,
|
||||
});
|
||||
}
|
||||
return Err(AppsApiError::AppNotFound(ident.to_string()));
|
||||
}
|
||||
apps.get_by_slug_or_history(ident)
|
||||
crate::app_repo::resolve_app(apps, ident)
|
||||
.await?
|
||||
.ok_or_else(|| AppsApiError::AppNotFound(ident.to_string()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user