|
1 | 1 | use std::fmt::Write;
|
2 | 2 |
|
3 | 3 | use anyhow::{Context as _, bail};
|
4 |
| -use octocrab::models::AuthorAssociation; |
5 | 4 |
|
6 | 5 | use crate::{
|
7 | 6 | config::ConcernConfig,
|
8 | 7 | github::{Event, Label},
|
9 | 8 | handlers::Context,
|
10 |
| - interactions::EditIssueBody, |
| 9 | + interactions::{EditIssueBody, ErrorComment}, |
11 | 10 | };
|
12 | 11 | use parser::command::concern::ConcernCommand;
|
13 | 12 |
|
@@ -68,22 +67,22 @@ pub(super) async fn handle_command(
|
68 | 67 | }
|
69 | 68 | }
|
70 | 69 |
|
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 | + { |
76 | 78 | 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", |
78 | 80 | issue_comment.repository.full_name,
|
79 | 81 | issue.number,
|
80 |
| - issue_comment.comment.author_association, |
| 82 | + issue_comment.comment.user, |
81 | 83 | );
|
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) |
87 | 86 | .await?;
|
88 | 87 | return Ok(());
|
89 | 88 | }
|
|
0 commit comments