Skip to content

Commit 9efcc37

Browse files
authored
Merge pull request #1909 from spastorino/properly-check-project-goals-acl
Properly check project goals ACL
2 parents 0fe372b + 6c513ef commit 9efcc37

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/handlers/project_goals.rs

+24-8
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,30 @@ impl Job for ProjectGoalsUpdateJob {
4545

4646
/// Returns true if the user with the given github id is allowed to ping all group people
4747
/// and do other "project group adminstrative" tasks.
48-
pub async fn check_project_goal_acl(_gh: &GithubClient, gh_id: u64) -> anyhow::Result<bool> {
49-
/// Github ID of the user allowed to ping all group people.
50-
///
51-
/// FIXME: We should create a team for the person/people managing the goals program
52-
/// and check that the zulip person is on it, but I'm too
53-
const GOAL_OWNER_GH_ID: u64 = 155238; // nikomatsakis
54-
55-
Ok(gh_id == GOAL_OWNER_GH_ID)
48+
pub async fn check_project_goal_acl(gh: &GithubClient, gh_id: u64) -> anyhow::Result<bool> {
49+
const GOALS_TEAM: &str = "goals";
50+
51+
let team = match github::get_team(gh, GOALS_TEAM).await {
52+
Ok(Some(team)) => team,
53+
Ok(None) => {
54+
log::info!("team ({}) failed to resolve to a known team", GOALS_TEAM);
55+
return Ok(false);
56+
}
57+
Err(err) => {
58+
log::error!(
59+
"team ({}) failed to resolve to a known team: {:?}",
60+
GOALS_TEAM,
61+
err
62+
);
63+
return Ok(false);
64+
}
65+
};
66+
67+
Ok(team
68+
.members
69+
.into_iter()
70+
.find(|member| member.github_id == gh_id)
71+
.is_some())
5672
}
5773

5874
async fn ping_project_goals_owners_automatically(gh: &GithubClient) -> anyhow::Result<()> {

0 commit comments

Comments
 (0)