Skip to content

Commit

Permalink
Add API call to hide a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Oct 24, 2024
1 parent d4b080b commit 2d280a1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@ pub struct Comment {
pub pr_review_state: Option<PullRequestReviewState>,
}

#[derive(Debug, serde::Deserialize, serde::Serialize, Eq, PartialEq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ReportedContentClassifiers {
Abuse,
Duplicate,
OffTopic,
Outdated,
Resolved,
Spam,
}

#[derive(Debug, serde::Deserialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum PullRequestReviewState {
Expand Down Expand Up @@ -617,6 +628,28 @@ impl Issue {
Ok(comment)
}

pub async fn hide_comment(
&self,
client: &GithubClient,
node_id: &str,
reason: ReportedContentClassifiers,
) -> anyhow::Result<()> {
client
.graphql_query(
"mutation($node_id: ID!, $reason: ReportedContentClassifiers!) {
minimizeComment(input: {subjectId: $node_id, classifier: $reason}) {
__typename
}
}",
serde_json::json!({
"node_id": node_id,
"reason": reason,
}),
)
.await?;
Ok(())
}

pub async fn remove_label(&self, client: &GithubClient, label: &str) -> anyhow::Result<()> {
log::info!("remove_label from {}: {:?}", self.global_id(), label);
// DELETE /repos/:owner/:repo/issues/:number/labels/{name}
Expand Down

0 comments on commit 2d280a1

Please sign in to comment.