Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental support for WebPush #177

Merged
merged 50 commits into from
Mar 17, 2021
Merged

Add experimental support for WebPush #177

merged 50 commits into from
Mar 17, 2021

Conversation

bwindels
Copy link
Contributor

@bwindels bwindels commented Mar 11, 2021

#176

Needs a change in a dependency so had to fork it for now, have a PR to merge it upstream at web-push-libs/pywebpush#133 This has been merged and released upstream.

@bwindels bwindels changed the title Webpush support Web Push support Mar 11, 2021
A service worker can only have 1 push subscription, but for web clients
that handle multiple matrix accounts like hydrogen, we want to be able
to enable push for every account. We can do that by setting a pusher
with the same web push details for each account, but we can't really
tell which account a push notification is for, so forward a session_id
set on the pusher data.
setup.py Outdated Show resolved Hide resolved
sygnal/webpushpushkin.py Outdated Show resolved Hide resolved
sygnal/webpushpushkin.py Outdated Show resolved Hide resolved
sygnal/webpushpushkin.py Outdated Show resolved Hide resolved
@bwindels
Copy link
Contributor Author

bwindels commented Mar 15, 2021

Tried to address as many outstanding issues as I could. A few things to note:

  • I've flat out copied the histogram/gauge code for connection handling from the GCM pushkin, and don't really know what I'm doing there, so perhaps a detailed look would be good
  • Do I need to add any specific opentracing logging?
  • I could use some help solving the typing errors. It seems to give an error on the libraries I added: pywebpush and py_vapid. Not sure how to solve that.

@bwindels bwindels requested a review from callahad March 15, 2021 19:48
@bwindels bwindels marked this pull request as ready for review March 16, 2021 08:15
@bwindels bwindels requested a review from clokep March 17, 2021 14:44
@clokep clokep removed the request for review from callahad March 17, 2021 18:13
@clokep
Copy link
Member

clokep commented Mar 17, 2021

@bwindels Can you double check over the changes I pushed and make sure they seem reasonable?

If so I think this is ✅ !

docs/applications.md Outdated Show resolved Hide resolved
@bwindels
Copy link
Contributor Author

Thank you for your changes @clokep! Lgtm (one minor comment).

docs/applications.md Outdated Show resolved Hide resolved
@clokep clokep changed the title Web Push support Add experimental support for WebPush Mar 17, 2021
@clokep clokep merged commit 5e259d8 into master Mar 17, 2021
@clokep clokep deleted the bwindels/webpush branch March 17, 2021 19:32
@@ -102,7 +102,7 @@ def __init__(self, name, sygnal, config):
raise PushkinSetupException("path in 'vapid_private_key' does not exist")
try:
self.vapid_private_key = Vapid.from_file(private_key_file=privkey_filename)
except BaseException as e:
Copy link
Contributor Author

@bwindels bwindels Mar 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had this first fwiw, but switched to the more general one because I assumed open and read here could throw some kind of I/O exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it's merged already 🎉 probably not too important in any case. Thanks for seeing this through!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had this first fwiw, but switched to the more general one because I assumed open and read here could throw some kind of I/O exception?

They could, but catching BaseExeption is usually not great. We check that the file exists above so I suspect that wouldn't happen...although I guess there could be permission issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants