Skip to content

Commit d6fa6da

Browse files
committed
models/team: Move is_gh_org_owner() fn into controller
This fn is unrelated to the database, so it should not live in the `models` module.
1 parent eea1e46 commit d6fa6da

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/controllers/krate/owners.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::controllers::krate::CratePath;
44
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;
66
use crate::models::{
77
krate::NewOwnerInvite, token::EndpointScope, CrateOwner, NewCrateOwnerInvitation,
88
NewCrateOwnerInvitationOutcome, NewTeam,
@@ -16,7 +16,7 @@ use axum::Json;
1616
use axum_extra::json;
1717
use axum_extra::response::ErasedJson;
1818
use chrono::Utc;
19-
use crates_io_github::GitHubClient;
19+
use crates_io_github::{GitHubClient, GitHubError};
2020
use diesel::prelude::*;
2121
use diesel_async::scoped_futures::ScopedFutureExt;
2222
use 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)]
441451
enum OwnerAddError {

src/models/team.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,6 @@ impl Team {
8282
}
8383
}
8484

85-
pub async fn is_gh_org_owner(
86-
gh_client: &dyn GitHubClient,
87-
org_id: i32,
88-
gh_login: &str,
89-
token: &AccessToken,
90-
) -> Result<bool, GitHubError> {
91-
let membership = gh_client.org_membership(org_id, gh_login, token).await?;
92-
Ok(membership.is_some_and(|m| m.is_active_admin()))
93-
}
94-
9585
pub async fn team_with_gh_id_contains_user(
9686
gh_client: &dyn GitHubClient,
9787
github_org_id: i32,

0 commit comments

Comments
 (0)