Skip to content

Commit 1e8452f

Browse files
LeSeulArtichautspastorinoMark-Simulacrum
committed
Adress review comments
Co-authored-by: spastorino <spastorino@gmail.com> Co-authored-by: Mark-Simulacrum <mark.simulacrum@gmail.com>
1 parent 7694ca8 commit 1e8452f

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub(crate) struct RelabelConfig {
7575

7676
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
7777
pub(crate) struct PrioritizeConfig {
78+
pub(crate) label: String,
7879
pub(crate) zulip_stream: u64,
7980
}
8081

src/handlers/prioritize.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,31 @@ async fn handle_input(ctx: &Context, config: &PrioritizeConfig, event: &Event) -
5858
};
5959

6060
let issue = event.issue().unwrap();
61-
if !is_team_member {
62-
let cmnt = ErrorComment::new(&issue, "Only Rust team members can prioritize issues.");
63-
cmnt.post(&ctx.github).await?;
64-
return Ok(());
65-
}
6661

67-
if issue.labels().iter().any(|l| l.name == "I-prioritize") {
68-
let cmnt = ErrorComment::new(&issue, "This issue is already prioritized!");
62+
if issue.labels().iter().any(|l| l.name == config.label) {
63+
let cmnt = ErrorComment::new(&issue, "This issue has already been requested for prioritization.");
6964
cmnt.post(&ctx.github).await?;
7065
return Ok(());
7166
}
7267

7368
let mut labels = issue.labels().to_owned();
7469
labels.push(github::Label {
75-
name: "I-prioritize".to_string(),
70+
name: config.label.clone(),
7671
});
7772
let github_req = issue.set_labels(&ctx.github, labels);
7873

79-
let mut zulip_topic = format!("I-pri #{} {}", issue.number, issue.title);
74+
let mut zulip_topic = format!("{} #{} {}", config.label, issue.number, issue.title);
8075
zulip_topic.truncate(60); // Zulip limitation
81-
let client = reqwest::Client::new(); // TODO: have a Zulip Client akin to GithubClient
82-
let zulip_req = client.post("https://rust-lang.zulipchat.com/api/v1/messages")
76+
77+
let zulip_req = ctx.github.raw().post("https://rust-lang.zulipchat.com/api/v1/messages")
8378
.form(&[
8479
("type", "stream"),
85-
("to", config.zulip_stream.to_string().as_str()),
80+
("to", &config.zulip_stream.to_string()),
8681
("topic", &zulip_topic),
87-
("content", "@*WG-prioritization*"),
82+
("content", &format!(
83+
"@*WG-prioritization* issue [#{}]({}) has been requested for prioritization.",
84+
issue.number, event.html_url().unwrap()
85+
)),
8886
])
8987
.send();
9088

0 commit comments

Comments
 (0)