22
33use crate :: controllers:: krate:: CratePath ;
44use crate :: models:: krate:: OwnerRemoveError ;
5- use crate :: models:: team:: { is_gh_org_owner , team_with_gh_id_contains_user} ;
5+ use crate :: models:: team:: team_with_gh_id_contains_user;
66use crate :: models:: {
77 krate:: NewOwnerInvite , token:: EndpointScope , CrateOwner , NewCrateOwnerInvitation ,
88 NewCrateOwnerInvitationOutcome , NewTeam ,
@@ -16,7 +16,7 @@ use axum::Json;
1616use axum_extra:: json;
1717use axum_extra:: response:: ErasedJson ;
1818use chrono:: Utc ;
19- use crates_io_github:: GitHubClient ;
19+ use crates_io_github:: { GitHubClient , GitHubError } ;
2020use diesel:: prelude:: * ;
2121use diesel_async:: scoped_futures:: ScopedFutureExt ;
2222use diesel_async:: { AsyncConnection , AsyncPgConnection , RunQueryDsl } ;
@@ -436,6 +436,16 @@ pub async fn create_or_update_github_team(
436436 . map_err ( Into :: into)
437437}
438438
439+ async fn is_gh_org_owner (
440+ gh_client : & dyn GitHubClient ,
441+ org_id : i32 ,
442+ gh_login : & str ,
443+ token : & AccessToken ,
444+ ) -> Result < bool , GitHubError > {
445+ let membership = gh_client. org_membership ( org_id, gh_login, token) . await ?;
446+ Ok ( membership. is_some_and ( |m| m. is_active_admin ( ) ) )
447+ }
448+
439449/// Error results from a [`add_owner()`] model call.
440450#[ derive( Debug , Error ) ]
441451enum OwnerAddError {
0 commit comments