Skip to content

Commit 2d280a1

Browse files
committed
1 parent d4b080b commit 2d280a1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/github.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,17 @@ pub struct Comment {
405405
pub pr_review_state: Option<PullRequestReviewState>,
406406
}
407407

408+
#[derive(Debug, serde::Deserialize, serde::Serialize, Eq, PartialEq)]
409+
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
410+
pub enum ReportedContentClassifiers {
411+
Abuse,
412+
Duplicate,
413+
OffTopic,
414+
Outdated,
415+
Resolved,
416+
Spam,
417+
}
418+
408419
#[derive(Debug, serde::Deserialize, Eq, PartialEq)]
409420
#[serde(rename_all = "snake_case")]
410421
pub enum PullRequestReviewState {
@@ -617,6 +628,28 @@ impl Issue {
617628
Ok(comment)
618629
}
619630

631+
pub async fn hide_comment(
632+
&self,
633+
client: &GithubClient,
634+
node_id: &str,
635+
reason: ReportedContentClassifiers,
636+
) -> anyhow::Result<()> {
637+
client
638+
.graphql_query(
639+
"mutation($node_id: ID!, $reason: ReportedContentClassifiers!) {
640+
minimizeComment(input: {subjectId: $node_id, classifier: $reason}) {
641+
__typename
642+
}
643+
}",
644+
serde_json::json!({
645+
"node_id": node_id,
646+
"reason": reason,
647+
}),
648+
)
649+
.await?;
650+
Ok(())
651+
}
652+
620653
pub async fn remove_label(&self, client: &GithubClient, label: &str) -> anyhow::Result<()> {
621654
log::info!("remove_label from {}: {:?}", self.global_id(), label);
622655
// DELETE /repos/:owner/:repo/issues/:number/labels/{name}

0 commit comments

Comments
 (0)