- Notifications
You must be signed in to change notification settings - Fork1k
feat(coderd): add webpush package#17091
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
1fdf10c
to86c481e
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We don't want to call this a notification of any kind because this will confuse with our existing notification targets. Instead we should call this something like PushMessage
Uh oh!
There was an error while loading.Please reload this page.
c44bdca
to1274623
Compare8dde95a
to449f882
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
First round done. I skipped "site" changes for now.
defercancel() | ||
ifregenVapidKeypairDBURL=="" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm quite sure I have seen this pattern in other CLI commands:
startBuiltinPostgres - codersdk.PostgresAuth - ConnectToPostgres
we may consider some base pattern for all commands using the database
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yep there are a few commands that do this. I'll create a follow-up. (EDIT:coder/internal#541)
// Ensure the push subscriptions were deleted. | ||
varcountint64 | ||
rows,err:=sqlDB.QueryContext(ctx,"SELECT COUNT(*) FROM webpush_subscriptions") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
just confirming - is there a chance that there will be another testrun operating on this table (flakiness risk?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There shouldn't be. It operates entirely in its own transaction, and each test should be operating on its own database.
postgres-builtin-serve Run the built-in PostgreSQL deployment. | ||
postgres-builtin-url Output the connection URL for the built-in | ||
PostgreSQL deployment. | ||
create-admin-userCreate a new admin user with the given username, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
nit: unrelated change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm actually not sure what's causing these changes, but the command to update these golden files is convinced that this is how it should be now.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
assert.Len(t,subscriptions,0,"No subscriptions should be returned") | ||
}) | ||
t.Run("FailedDelivery",func(t*testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
do we want to implement retry mechanism at some point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yes, we will need to do this later if we make it a first-class notifciation target.
Uh oh!
There was an error while loading.Please reload this page.
} | ||
typeWebpushMessagestruct { | ||
Iconstring`json:"icon"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
In the notification payload we use version for potential schema changes. Should we adopt this pattern too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Not a bad idea! It might be slightly premature right now, but I could see this being useful down the line.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Cosmetics
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
06e5d9e
intomainUh oh!
There was an error while loading.Please reload this page.
/cherry-pick release/2.21 |
Uh oh!
There was an error while loading.Please reload this page.
Extracted fromhttps://github.com/coder/coder/tree/kyle/tasks
This PR adds a
webpush
package undercoderd
to allow sending push notifications to browsers from coderd using Web Push andVAPID.Why VAPID? Why not just dial the agent directly?
It is not yet hooked up to the wider notifications ecosystem inside Coder, and is therefore hidden behind an experiment
web-push
. This simply adds the package and a minimal service worker + button in the UI. Later PRs will build further upon this.Adds
codersdk.ExperimentWebPush
(web-push
)Adds a
coderd/webpush
package that allows sending native push notifications viagithub.com/SherClockHolmes/webpush-go
Adds database tables to store push notification subscriptions.
Adds an API endpoint that allows users to subscribe/unsubscribe, and send a test notification
Adds server CLI command to regenerate VAPID keys (note: regenerating the VAPID keypair requires deleting all existing subscriptions)
* Adds a service worker to display push notificationsEDIT: moved tofeat(site): add webpush notification serviceworker #17123