@@ -19,7 +19,7 @@ use crate::{
1919 api:: {
2020 MonoApiServiceState ,
2121 api_common:: group_permission:: {
22- build_user_effective_permission_response, ensure_admin, parse_resource_context ,
22+ build_user_effective_permission_response, ensure_admin, resolve_resource_context ,
2323 } ,
2424 error:: ApiError ,
2525 oauth:: model:: LoginUser ,
@@ -393,7 +393,7 @@ async fn list_group_members(
393393 ( status = 400 , description = "Invalid request" ) ,
394394 ( status = 401 , description = "Unauthorized" ) ,
395395 ( status = 403 , description = "Forbidden - admin only" ) ,
396- ( status = 404 , description = "Group not found" ) ,
396+ ( status = 404 , description = "Resource or group not found" ) ,
397397 ) ,
398398 tag = GROUP_PERMISSION_TAG
399399) ]
@@ -405,7 +405,7 @@ async fn set_resource_permissions(
405405) -> Result < Json < CommonResult < Vec < ResourcePermissionResponse > > > , ApiError > {
406406 ensure_admin ( & state, & user) . await ?;
407407 let ( resource_type, _, resource_id) =
408- parse_resource_context ( resource_type. as_str ( ) , & resource_id) ?;
408+ resolve_resource_context ( & state , resource_type. as_str ( ) , & resource_id) . await ?;
409409
410410 let permissions = req
411411 . permissions
@@ -437,6 +437,7 @@ async fn set_resource_permissions(
437437 ( status = 400 , description = "Invalid request" ) ,
438438 ( status = 401 , description = "Unauthorized" ) ,
439439 ( status = 403 , description = "Forbidden - admin only" ) ,
440+ ( status = 404 , description = "Resource not found" ) ,
440441 ) ,
441442 tag = GROUP_PERMISSION_TAG
442443) ]
@@ -447,7 +448,7 @@ async fn get_resource_permissions(
447448) -> Result < Json < CommonResult < Vec < ResourcePermissionResponse > > > , ApiError > {
448449 ensure_admin ( & state, & user) . await ?;
449450 let ( resource_type, _, resource_id) =
450- parse_resource_context ( resource_type. as_str ( ) , & resource_id) ?;
451+ resolve_resource_context ( & state , resource_type. as_str ( ) , & resource_id) . await ?;
451452
452453 let permissions = state
453454 . monorepo ( )
@@ -471,7 +472,7 @@ async fn get_resource_permissions(
471472 ( status = 400 , description = "Invalid request" ) ,
472473 ( status = 401 , description = "Unauthorized" ) ,
473474 ( status = 403 , description = "Forbidden - admin only" ) ,
474- ( status = 404 , description = "Group not found" ) ,
475+ ( status = 404 , description = "Resource or group not found" ) ,
475476 ) ,
476477 tag = GROUP_PERMISSION_TAG
477478) ]
@@ -483,7 +484,7 @@ async fn update_resource_permissions(
483484) -> Result < Json < CommonResult < Vec < ResourcePermissionResponse > > > , ApiError > {
484485 ensure_admin ( & state, & user) . await ?;
485486 let ( resource_type, _, resource_id) =
486- parse_resource_context ( resource_type. as_str ( ) , & resource_id) ?;
487+ resolve_resource_context ( & state , resource_type. as_str ( ) , & resource_id) . await ?;
487488
488489 let permissions = req
489490 . permissions
@@ -515,6 +516,7 @@ async fn update_resource_permissions(
515516 ( status = 400 , description = "Invalid request" ) ,
516517 ( status = 401 , description = "Unauthorized" ) ,
517518 ( status = 403 , description = "Forbidden - admin only" ) ,
519+ ( status = 404 , description = "Resource not found" ) ,
518520 ) ,
519521 tag = GROUP_PERMISSION_TAG
520522) ]
@@ -525,7 +527,7 @@ async fn delete_resource_permissions(
525527) -> Result < Json < CommonResult < DeletePermissionsResponse > > , ApiError > {
526528 ensure_admin ( & state, & user) . await ?;
527529 let ( resource_type, resource_type_value, resource_id) =
528- parse_resource_context ( resource_type. as_str ( ) , & resource_id) ?;
530+ resolve_resource_context ( & state , resource_type. as_str ( ) , & resource_id) . await ?;
529531
530532 let deleted_count = state
531533 . monorepo ( )
@@ -583,6 +585,7 @@ async fn get_user_groups(
583585 ( status = 400 , description = "Invalid request" ) ,
584586 ( status = 401 , description = "Unauthorized" ) ,
585587 ( status = 403 , description = "Forbidden - admin only" ) ,
588+ ( status = 404 , description = "Resource not found" ) ,
586589 ) ,
587590 tag = GROUP_PERMISSION_TAG
588591) ]
@@ -593,7 +596,7 @@ async fn get_user_effective_permission(
593596) -> Result < Json < CommonResult < UserEffectivePermissionResponse > > , ApiError > {
594597 ensure_admin ( & state, & user) . await ?;
595598 let ( resource_type, resource_type_value, resource_id) =
596- parse_resource_context ( resource_type. as_str ( ) , & resource_id) ?;
599+ resolve_resource_context ( & state , resource_type. as_str ( ) , & resource_id) . await ?;
597600
598601 let effective = state
599602 . monorepo ( )
0 commit comments