Skip to content

Commit c5e8b12

Browse files
joshtriplettCentril
authored andcommitted
Allow a member of any team to initiate a poll (#237)
1 parent ce8e298 commit c5e8b12

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/github/nag.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,27 @@ pub fn update_nags(comment: &IssueComment) -> DashResult<()> {
5353
.first::<GitHubUser>(conn)?;
5454

5555
let subteam_members = subteam_members(&issue)?;
56+
let all_team_members = all_team_members()?;
5657

5758
// Attempt to parse all commands out of the comment
5859
let mut any = false;
5960
for command in RfcBotCommand::from_str_all(&SETUP, &comment.body) {
6061
any = true;
6162

62-
// Don't accept bot commands from non-subteam members.
63-
// Early return because we'll just get here again...
64-
if subteam_members.iter().find(|&u| u == &author).is_none() {
65-
info!("command author ({}) doesn't appear in any relevant subteams",
66-
author.login);
67-
return Ok(());
63+
if let RfcBotCommand::StartPoll {..} = command {
64+
// Accept poll requests from any known user.
65+
if all_team_members.iter().find(|&u| u == &author).is_none() {
66+
info!("poll requester ({}) is not a known user", author.login);
67+
return Ok(());
68+
}
69+
} else {
70+
// Don't accept most bot commands from non-subteam members.
71+
// Early return because we'll just get here again...
72+
if subteam_members.iter().find(|&u| u == &author).is_none() {
73+
info!("command author ({}) doesn't appear in any relevant subteams",
74+
author.login);
75+
return Ok(());
76+
}
6877
}
6978

7079
debug!("processing rfcbot command: {:?}", &command);
@@ -633,6 +642,12 @@ where
633642
)
634643
}
635644

645+
/// Return a list of all known team members.
646+
fn all_team_members() -> DashResult<Vec<GitHubUser>>
647+
{
648+
specific_subteam_members(|_| true)
649+
}
650+
636651
/// Check if an issue comment is written by a member of one of the subteams
637652
/// labelled on the issue.
638653
fn subteam_members(issue: &Issue) -> DashResult<Vec<GitHubUser>> {

0 commit comments

Comments
 (0)