Skip to content

Commit 221dfed

Browse files
committed
Use team repo to determine membership for the concern command
1 parent 817268e commit 221dfed

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/handlers/concern.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use std::fmt::Write;
22

33
use anyhow::{Context as _, bail};
4-
use octocrab::models::AuthorAssociation;
54

65
use crate::{
76
config::ConcernConfig,
87
github::{Event, Label},
98
handlers::Context,
10-
interactions::EditIssueBody,
9+
interactions::{EditIssueBody, ErrorComment},
1110
};
1211
use parser::command::concern::ConcernCommand;
1312

@@ -68,22 +67,22 @@ pub(super) async fn handle_command(
6867
}
6968
}
7069

71-
// Verify that the comment author is at least a member of the org, error if it's not
72-
if !matches!(
73-
issue_comment.comment.author_association,
74-
AuthorAssociation::Member | AuthorAssociation::Owner
75-
) {
70+
// Verify that the comment author is a team member in our team repo
71+
if !issue_comment
72+
.comment
73+
.user
74+
.is_team_member(&ctx.team)
75+
.await
76+
.context("failed to verify that the user is a team member")?
77+
{
7678
tracing::info!(
77-
"{}#{} tried to register a concern, but author association isn't right: {:?}",
79+
"{}#{} tried to register a concern, but comment author {:?} is not part of the team repo",
7880
issue_comment.repository.full_name,
7981
issue.number,
80-
issue_comment.comment.author_association,
82+
issue_comment.comment.user,
8183
);
82-
issue
83-
.post_comment(
84-
&ctx.github,
85-
"Only organization members can add or resolve concerns.",
86-
)
84+
ErrorComment::new(&issue, "Only team members in the [team repo](https://github.com/rust-lang/team) can add or resolve concerns.")
85+
.post(&ctx.github)
8786
.await?;
8887
return Ok(());
8988
}

0 commit comments

Comments
 (0)