snarfed / bridgy

📣 Connects your web site to social media. Likes, retweets, mentions, cross-posting, and more...
https://brid.gy
Creative Commons Zero v1.0 Universal
720 stars 52 forks source link

GitHub Publish: support emoji reactions on PR comments #955

Open tantek opened 4 years ago

tantek commented 4 years ago

GitHub pull requests accept reacji just like comments, issues, etc. But currently Bridgy seems to not recognize reacji in reply to a pull request review permalink like:

https://github.com/w3c/PWETF/pull/143#issuecomment-651990278

And returned this error:

> 2020-06-30 20:05:17.817455 Please remove the fragment #pullrequestreview-440206392 from your in-reply-to URL.

Expected result: apply the reacji to the pull request review.

Label: publish.

(Originally published at: https://tantek.com/2020/182/b1/)

snarfed commented 3 years ago

Looking at the API, we currently use the /repos/%s/%s/issues/comments/%s/reactions endpoint for issue comments, and this may be as trivial as replacing issues with pulls. Or it might even work without that. Will see.

snarfed commented 3 years ago

So I managed to get this to work for line-level PR comments, eg https://github.com/snarfed/granary/pull/222#discussion_r504059098, but not for top-level PR comments like you mention, eg https://github.com/snarfed/bridgy/pull/906#pullrequestreview-337375271 . No clue why.

Attempting to fetch those #pullrequestreview-* comments with GET /repos/.../.../pulls/comments/... fails with HTTP 404:

{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/pulls#get-a-review-comment-for-a-pull-request"
}

...and attempting to create one with POST /repos/.../.../pulls/comments/... fails with HTTP 403:

{
  "message": "Insufficient scopes for reacting to this Pull Request Review Comment.",
  "documentation_url": "https://docs.github.com/rest/reference/reactions#create-reaction-for-a-pull-request-review-comment"
}

(I scoured https://docs.github.com/en/rest/reference/permissions-required-for-github-apps trying to figure out which scopes I was missing. Bridgy already gets public_repo, which should be everything we need. I tried write:discussion too, but no luck.)

https://docs.github.com/en/rest/reference/pulls says "Comments on pull requests can be managed via the Issue Comments API," but I get the same errors on the issues version of that API endpoint. Ugh. 🤷