2
2
3
3
use crate :: controllers:: krate:: CratePath ;
4
4
use 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;
6
6
use crate :: models:: {
7
7
krate:: NewOwnerInvite , token:: EndpointScope , CrateOwner , NewCrateOwnerInvitation ,
8
8
NewCrateOwnerInvitationOutcome , NewTeam ,
@@ -16,7 +16,7 @@ use axum::Json;
16
16
use axum_extra:: json;
17
17
use axum_extra:: response:: ErasedJson ;
18
18
use chrono:: Utc ;
19
- use crates_io_github:: GitHubClient ;
19
+ use crates_io_github:: { GitHubClient , GitHubError } ;
20
20
use diesel:: prelude:: * ;
21
21
use diesel_async:: scoped_futures:: ScopedFutureExt ;
22
22
use diesel_async:: { AsyncConnection , AsyncPgConnection , RunQueryDsl } ;
@@ -436,6 +436,16 @@ pub async fn create_or_update_github_team(
436
436
. map_err ( Into :: into)
437
437
}
438
438
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
+
439
449
/// Error results from a [`add_owner()`] model call.
440
450
#[ derive( Debug , Error ) ]
441
451
enum OwnerAddError {
0 commit comments