Skip to content

Commit ab5d171

Browse files
committed
Extract GitHubOrgMembership::is_active_admin() fn
1 parent 44a1813 commit ab5d171

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

crates/crates_io_github/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ pub struct GitHubOrgMembership {
218218
pub role: String,
219219
}
220220

221+
impl GitHubOrgMembership {
222+
pub fn is_active_admin(&self) -> bool {
223+
self.state == "active" && self.role == "admin"
224+
}
225+
}
226+
221227
#[derive(Debug, Deserialize, Clone, Eq, Hash, PartialEq)]
222228
pub struct GitHubPublicKey {
223229
pub key_identifier: String,

src/models/team.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ async fn is_gh_org_owner(
217217
token: &AccessToken,
218218
) -> Result<bool, GitHubError> {
219219
let membership = gh_client.org_membership(org_id, gh_login, token).await?;
220-
Ok(membership.is_some_and(|m| m.state == "active" && m.role == "admin"))
220+
Ok(membership.is_some_and(|m| m.is_active_admin()))
221221
}
222222

223223
async fn team_with_gh_id_contains_user(

0 commit comments

Comments
 (0)