(
owner: &str,
repo: &str,
issue_number: Option<u64>,
comment_id: Option<u64>,
comment_type: Option<&str>,
token: Option<&str>,
)
| 4758 | } |
| 4759 | |
| 4760 | fn github_add_reaction( |
| 4761 | owner: &str, |
| 4762 | repo: &str, |
| 4763 | issue_number: Option<u64>, |
| 4764 | comment_id: Option<u64>, |
| 4765 | comment_type: Option<&str>, |
| 4766 | token: Option<&str>, |
| 4767 | ) -> Option<GithubReactionHandle> { |
| 4768 | let create_endpoint = match (comment_type, comment_id, issue_number) { |
| 4769 | (Some("pr_review"), Some(comment_id), _) => { |
| 4770 | format!("repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions") |
| 4771 | } |
| 4772 | (Some("issue"), Some(comment_id), _) => { |
| 4773 | format!("repos/{owner}/{repo}/issues/comments/{comment_id}/reactions") |
| 4774 | } |
| 4775 | (_, _, Some(issue_number)) => { |
| 4776 | format!("repos/{owner}/{repo}/issues/{issue_number}/reactions") |
| 4777 | } |
| 4778 | _ => return None, |
| 4779 | }; |
| 4780 | |
| 4781 | let reaction = gh_api_json( |
| 4782 | "POST", |
| 4783 | &create_endpoint, |
| 4784 | Some(&serde_json::json!({ "content": "eyes" })), |
| 4785 | token, |
| 4786 | ) |
| 4787 | .ok()?; |
| 4788 | let reaction_id = reaction.get("id").and_then(|v| v.as_u64())?; |
| 4789 | Some(GithubReactionHandle { |
| 4790 | delete_endpoint: format!("{}/{}", create_endpoint, reaction_id), |
| 4791 | }) |
| 4792 | } |
| 4793 | |
| 4794 | fn github_remove_reaction(reaction: &GithubReactionHandle, token: Option<&str>) { |
| 4795 | let _ = gh_api_json("DELETE", &reaction.delete_endpoint, None, token); |
no test coverage detected