Skip to content

Commit d4b080b

Browse files
committed
1 parent f563bc9 commit d4b080b

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/github.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ impl ZulipGitHubReference {
391391

392392
#[derive(Debug, serde::Deserialize)]
393393
pub struct Comment {
394+
pub id: u64,
395+
pub node_id: String,
394396
#[serde(deserialize_with = "opt_string")]
395397
pub body: String,
396398
pub html_url: String,
@@ -581,24 +583,24 @@ impl Issue {
581583
client: &GithubClient,
582584
id: u64,
583585
new_body: &str,
584-
) -> anyhow::Result<()> {
586+
) -> anyhow::Result<Comment> {
585587
let comment_url = format!("{}/issues/comments/{}", self.repository().url(client), id);
586588
#[derive(serde::Serialize)]
587589
struct NewComment<'a> {
588590
body: &'a str,
589591
}
590-
client
591-
.send_req(
592+
let comment = client
593+
.json(
592594
client
593595
.patch(&comment_url)
594596
.json(&NewComment { body: new_body }),
595597
)
596598
.await
597599
.context("failed to edit comment")?;
598-
Ok(())
600+
Ok(comment)
599601
}
600602

601-
pub async fn post_comment(&self, client: &GithubClient, body: &str) -> anyhow::Result<()> {
603+
pub async fn post_comment(&self, client: &GithubClient, body: &str) -> anyhow::Result<Comment> {
602604
#[derive(serde::Serialize)]
603605
struct PostComment<'a> {
604606
body: &'a str,
@@ -608,11 +610,11 @@ impl Issue {
608610
.strip_prefix("https://api.github.com")
609611
.expect("expected api host");
610612
let comments_url = format!("{}{comments_path}", client.api_url);
611-
client
612-
.send_req(client.post(&comments_url).json(&PostComment { body }))
613+
let comment = client
614+
.json(client.post(&comments_url).json(&PostComment { body }))
613615
.await
614616
.context("failed to post comment")?;
615-
Ok(())
617+
Ok(comment)
616618
}
617619

618620
pub async fn remove_label(&self, client: &GithubClient, label: &str) -> anyhow::Result<()> {

src/interactions.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ impl<'a> ErrorComment<'a> {
2626
"Please file an issue on GitHub at [triagebot](https://github.com/rust-lang/triagebot) if there's \
2727
a problem with this bot, or reach out on [#t-infra](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra) on Zulip."
2828
)?;
29-
self.issue.post_comment(client, &body).await
29+
self.issue.post_comment(client, &body).await?;
30+
Ok(())
3031
}
3132
}
3233

@@ -45,7 +46,8 @@ impl<'a> PingComment<'a> {
4546
for user in self.users {
4647
write!(body, "@{} ", user)?;
4748
}
48-
self.issue.post_comment(client, &body).await
49+
self.issue.post_comment(client, &body).await?;
50+
Ok(())
4951
}
5052
}
5153

0 commit comments

Comments
 (0)