slapperwan / gh4a

Github client for Android
Apache License 2.0
1.73k stars 221 forks source link

[RFE] add button for watching an issue #215

Open mathstuf opened 10 years ago

mathstuf commented 10 years ago

This way I can watch an issue without making a dummy comment (see #129).

maniac103 commented 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).

mathstuf commented 10 years ago

I guess a label for "needs-api-support" would be good then for this issue?

maniac103 commented 10 years ago

Good idea :)

mathstuf commented 10 years ago

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.

maniac103 commented 10 years ago

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.

mathstuf commented 10 years ago

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.

myrdd commented 10 years ago

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 commented 9 years ago

Is not this https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription?

myrdd commented 9 years ago

@bhack Looks like the API interface we are looking for.

maniac103 commented 9 years ago

I think I found that one earlier; what I missed was a way to find out the thread ID.

alorma commented 9 years ago

There's no way to get the thread ID, until you get the notification...

Asked to github team.

maniac103 commented 9 years ago

Thanks. So it looks like watching an issue indeed isn't possible with the current API.

mammuth commented 8 years ago

So, were there any related API changes in the last year so subscribing might work?

mathstuf commented 8 years ago

I don't see any relevant API endpoints still :( .

sbrl commented 7 years ago

Any status updates on this? (I'm posting this comment primarily to subscribe to this issue lol)

mammuth commented 7 years ago

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.

sbrl commented 7 years ago

That's annoying. I could really use it, too 😕

Bluscream commented 7 years ago

How does the browser get the thread id?

maniac103 commented 7 years ago

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.

Bluscream commented 7 years ago

Can't octodroid simply emulate that?

maniac103 commented 7 years ago

No, it can't. We'll stick to the API, everything else us not supportable.

jancborchardt commented 7 years ago

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?

Tunous commented 7 years ago

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.

laughedelic commented 7 years ago

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.

maniac103 commented 7 years ago

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:

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.

laughedelic commented 7 years ago

You are right! I shouldn't have interpreted it this way before testing as you did 👍

nogweii commented 6 years ago

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.

mathstuf commented 5 years ago

It looks like the GraphQL API has support for changing subscriptions.

KaKi87 commented 4 years ago

Hello, any news on this ?

mathstuf commented 4 years ago

605 seems to be the relevant issue there. The app would need to be ported to use GraphQL. https://blog.apollographql.com/launching-apollo-graphql-on-android-40ee0b5789bd?gi=46c44c646e07 seems like a promising way to do it (though I just did a simple search and other libraries may do it better in the time since that post).

KaKi87 commented 4 years ago

Or the app could query the same endpoint the client does, regardless of it's official or not.

mathstuf commented 4 years ago

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.

KaKi87 commented 4 years ago

So you prefer to wait for the more complicated implementation and have nothing in the meantime instead of implementing something when we can ?

maniac103 commented 4 years ago

when we can

We can? Did I miss a pull request? :-P

KaKi87 commented 4 years ago

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

mathstuf commented 4 years ago

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).

iamtalhaasghar commented 3 years ago

Any updates on this issue?

mathstuf commented 3 years ago

AFAICT, there's still no API for this. :(

Mynacol commented 2 months ago

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?

mathstuf commented 2 months ago

Looks like GraphQL might have something now: https://docs.github.com/en/graphql/reference/interfaces#subscribable