gh4a icon indicating copy to clipboard operation
gh4a copied to clipboard

[RFE] add button for watching an issue

Open mathstuf opened this issue 11 years ago • 42 comments

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

mathstuf avatar Sep 25 '14 02:09 mathstuf

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

maniac103 avatar Sep 25 '14 07:09 maniac103

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

mathstuf avatar Sep 25 '14 14:09 mathstuf

Good idea :)

maniac103 avatar Sep 25 '14 14:09 maniac103

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.

mathstuf avatar Sep 25 '14 15:09 mathstuf

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.

maniac103 avatar Sep 25 '14 17:09 maniac103

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.

mathstuf avatar Sep 25 '14 17:09 mathstuf

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

myrdd avatar Nov 26 '14 21:11 myrdd

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

bhack avatar May 20 '15 23:05 bhack

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

myrdd avatar May 20 '15 23:05 myrdd

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

maniac103 avatar May 21 '15 04:05 maniac103

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

Asked to github team.

alorma avatar May 21 '15 04:05 alorma

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

maniac103 avatar May 21 '15 04:05 maniac103

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

mammuth avatar Jun 02 '16 07:06 mammuth

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

mathstuf avatar Jun 02 '16 13:06 mathstuf

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

sbrl avatar Apr 20 '17 20:04 sbrl

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.

mammuth avatar Apr 20 '17 21:04 mammuth

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

sbrl avatar Apr 20 '17 21:04 sbrl

How does the browser get the thread id?

Bluscream avatar Sep 01 '17 08:09 Bluscream

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.

maniac103 avatar Sep 01 '17 08:09 maniac103

Can't octodroid simply emulate that?

Bluscream avatar Sep 01 '17 15:09 Bluscream

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

maniac103 avatar Sep 01 '17 15:09 maniac103

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?

jancborchardt avatar Sep 08 '17 11:09 jancborchardt

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.

Tunous avatar Sep 08 '17 11:09 Tunous

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.

laughedelic avatar Oct 24 '17 11:10 laughedelic

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.

maniac103 avatar Oct 24 '17 11:10 maniac103

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

laughedelic avatar Oct 24 '17 11:10 laughedelic

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.

nogweii avatar Mar 24 '18 09:03 nogweii

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

mathstuf avatar Oct 25 '19 00:10 mathstuf

Hello, any news on this ?

KaKi87 avatar Feb 07 '20 19:02 KaKi87

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

mathstuf avatar Feb 10 '20 05:02 mathstuf