sindresorhus / notifier-for-github

Browser extension - Get notified about new GitHub notifications
MIT License
1.83k stars 132 forks source link

Show notification shelf with `notification_referrer_id` #268

Open danopia opened 2 years ago

danopia commented 2 years ago

Hi, reviving #237 because it seems possible to generate the ID which makes notification deeplinks easier to 'action' after opening.

https://github.com/manosim/gitify/pull/519 shows another project implementing the token as effectively:

btoa(`018:NotificationThread${notificationId}:${userId}`)

I've noticed that the notifications page is using a different format now, and I built this expression for it, though I'm not sure what the 6 leading bytes represent:

'NT_'+btoa(`\x93\x00\xCD\x9E\xB4\xB0${notificationId}:${userId}`).replace(/=+$/, '')

Both of these expressions create working tokens for me. I'd like to confer with another user about the binary in the newer tokens to see if it's the same for everyone. But the old tokens seem pretty straightforward to try out too!

Of course, it's possible that the tokens will change / stop working someday, and it should leave the tool back at the current functionality. So it seems reasonable to try. The only other complication is getting user id. Either letting the user opt-in to the feature by adding a User ID box in settings, or asking for a scope that will include the user endpoint.

If this feature is still considered out of scope for the project, I apologize for the noise! I installed this tool a couple days ago and have been really enjoying the UX of the desktop notifications. Being able to hit 'done' too would make it that much better.

Nadrieril commented 4 months ago

Tried this today (2 years later), and you approach seems to work, except the magic bits I needed were '\x93\x00\xCE\x00\x67\x82\xa6\xb2'. I don't know if it's because GitHub has changed since or if these bits are user-specific in some way.

PS: tysm for figuring this out, I've now got notification shelf working for a small cli tool I'm building!

danopia commented 4 months ago

Thanks for the extra info. I just clicked an arbitrary notification and got the magic bytes \x93\x00\xCD\x9E\xB4\xB1 which is only one bit off from the sample in my 2022 comment. And I checked with a second Github user which has yet another string of arbitrary bytes. So there's definitely some extra user-specific magic to this value, rather unfortunate. (I tried finding more independent research on Google and landed back at this thread. 😄)