Open mathstuf opened 10 years ago
Unfortunately, it looks there's no way to do this with the Github API :-( I can't find a way to subscribe to anything that's not a repository (be it an issue or a pull request).
I guess a label for "needs-api-support" would be good then for this issue?
Good idea :)
Using the Firefox inspector, it looks like GitHub just sends a POST to notifications/threads
with the Referer
header set to what you want to subscribe to or unsubscribe from.
Can you post the full request for a subscription request for any issue in this repo? (I can't as I'm automatically subscribed due to being a collaborator) The docs ( https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription) say one needs a thread id, but it's not obvious where this id comes from.
On Thu, Sep 25, 2014 at 10:32:54 -0700, maniac103 wrote:
Can you post the full request for a subscription request for any issue in this repo? (I can't as I'm automatically subscribed due to being a collaborator) The docs ( https://developer.github.com/v3/activity/notifications/# set-a-thread-subscription) say one needs a thread id, but it's not obvious where this id comes from.
Looking at the parameters sent:
utf8: "✓"
authenticity_token: "..."
repository_id: "1388190"
thread_id: "43842983"
thread_class: "Issue"
id: "unsubscribe"
I see this in the page's source code:
data-channel="slapperwan/gh4a:issue:43842983"
There is also a <meta>
tag for the repository_id
value, but not one
for the thread.
This would be a really nice featue :)
I can confirm that the browser sends a POST
request to https://github.com/notifications/thread
, the referer being e.g. https://github.com/danieloeh/AntennaPod/issues/100
.
When subscribing, the request body remains the same; it's simply subscribe
instead of unsubscribe
.
utf8=%E2%9C%93
&authenticity_token=…
&repository_id=5244445
&thread_id=10139376
&thread_class=Issue
&id=subscribe
@bhack Looks like the API interface we are looking for.
I think I found that one earlier; what I missed was a way to find out the thread ID.
There's no way to get the thread ID, until you get the notification...
Asked to github team.
Thanks. So it looks like watching an issue indeed isn't possible with the current API.
So, were there any related API changes in the last year so subscribing might work?
I don't see any relevant API endpoints still :( .
Any status updates on this? (I'm posting this comment primarily to subscribe to this issue lol)
I just talked to the Github support some days ago, just about this issue. There is still no way to retrieve the thread ID without a notification. They know about this but they were not able to provide me a roadmap or information on whether / when this might be resolved.
That's annoying. I could really use it, too 😕
How does the browser get the thread id?
Github's web frontend doesn't use the official API, but a combination of server-side rendered pages and an unofficial API. They simply have more possibilities.
Can't octodroid simply emulate that?
No, it can't. We'll stick to the API, everything else us not supportable.
In the notifications view though there is a menu entry to "Unsubscribe". Couldn't the same "Subscribe"/" Unsubscribe" toggle be shown in the 3-dot-menu of an issue view?
Nope, notifications API does provide subscription id but it's not available when accessing the issue by itself and there is no way to request this separately either.
notifications API does provide subscription id but it's not available when accessing the issue by itself
It is available (at least now) in the response for the GET /repos/:owner/:repo/issues/:number
request (see the id
parameter). See for example this issue:
"id": 43842983,
"number": 215,
As far as I understand this id
is the "thread id" that can be used to subscribe/unsubscribe through the notifications API.
As far as I understand this id is the "thread id" that can be used to subscribe/unsubscribe through the notifications API.
How did you come to this conclusion? I don't think it's the case. As an example:
curl https://api.github.com/repos/slapperwan/gh4a/issues/777
[...]
"id": 265823140,
"number": 777,
[...]
curl -H "Authorization: Token XXX" https://api.github.com/notifications
[...]
"id": "267086772",
"unread": true,
"reason": "mention",
"updated_at": "2017-10-20T13:58:47Z",
"last_read_at": "2017-10-16T18:01:45Z",
"subject": {
"title": "Line comments being typed lost on portrait/landscape rotation",
"url": "https://api.github.com/repos/slapperwan/gh4a/issues/777",
"latest_comment_url": "https://api.github.com/repos/slapperwan/gh4a/issues/comments/338214630",
"type": "Issue"
},
[...]
"subscription_url": "https://api.github.com/notifications/threads/267086772/subscription"
[...]
So - AFAICT - issue ID and subscription ID is not the same thing. Consequently,
curl -X PUT -d subscribed=false -d ignored=false -H "Authorization: Token XXX" https://api.github.com/notifications/threads/265823140/subscription
yields
{
"message": "Must have admin rights to Repository.",
"documentation_url": "https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription"
}
so it seems to have interpreted the ID differently.
You are right! I shouldn't have interpreted it this way before testing as you did 👍
It seems like you could query https://github.com/USERNAME/REPONAME/issues/ISSUE_ID/show_partial?partial=issues%2Ftitle
and parse out data-channel (looks like "issue:THREAD_ID") from there. Definitely unofficial API, however.
It looks like the GraphQL API has support for changing subscriptions.
Hello, any news on this ?
Or the app could query the same endpoint the client does, regardless of it's official or not.
GitHub is not shy about breaking undocumented APIs. The thread ID scraping could break, the endpoint parameter could change, etc. They may also block apps using them (especially now that they have a supported endpoint for it). It's better to use the correct APIs for these kinds of things.
So you prefer to wait for the more complicated implementation and have nothing in the meantime instead of implementing something when we can ?
when we can
We can? Did I miss a pull request? :-P
Sorry I code JS not Java 😅 What I mean : you said that GraphQL migration would be the most complicated option, so using the user endpoint would be easier
So you prefer to wait for the more complicated implementation and have nothing in the meantime instead of implementing something when we can ?
As said above, if it were so easy, why isn't it already done by now? The main issue here is gathering the data for the query since the data is spread around the HTML page (not any API object you get back for an issue).
Any updates on this issue?
AFAICT, there's still no API for this. :(
I wanted a convenient watch/unsubscribe button in this app and found this old issue. Can someone check if there's an API method nowadays?
Looks like GraphQL might have something now: https://docs.github.com/en/graphql/reference/interfaces#subscribable
This way I can watch an issue without making a dummy comment (see #129).