server: always enable push notifications #235

Merged
norm merged 2 commits from enable-push-notifs into main 2022-11-29 21:51:10 +00:00
Owner

The thing that previously presumably hindered this was that the VAPID keys had to be set up. Previously admins had to do this, but this is a bad idea for multiple reasons:

  1. The meaning of "public key" and "private key" was not well documented in the settings.
  2. Giving out a private key over the API, even just for admins, sounds like a bad idea.
The thing that previously presumably hindered this was that the VAPID keys had to be set up. Previously admins had to do this, but this is a bad idea for multiple reasons: 1) The meaning of "public key" and "private key" was not well documented in the settings. 2) Giving out a private key over the API, even just for admins, sounds like a bad idea.
Owner

It looks like that migration might not be working properly: https://toot.site/@jeder/109382304525913598

It looks like that migration might not be working properly: https://toot.site/@jeder/109382304525913598
Johann150 force-pushed enable-push-notifs from 7a82a3d262 to 36c3e1ccc5 2022-11-21 19:58:20 +00:00 Compare
norm requested changes 2022-11-21 20:31:26 +00:00
@ -0,0 +7,4 @@
// generate VAPID keys if not yet set
const keysSet = await queryRunner.query(`SELECT "swPublicKey" IS NOT NULL AND "swPrivateKey" IS NOT NULL as set FROM "meta"`);
// if there is no meta entry yet, the keys will be generated on initial setup
if (keysSet.length > 0 && !keysSet.set) {
Owner

This check should be keysSet.length === 0 and the query should be

SELECT "swPublicKey", "swPrivateKey" FROM "meta" where "swPublicKey" IS NOT NULL AND "swPrivateKey" IS NOT NULL

Otherwise this doesn't get run and will result in a non-null constraint error.

This check should be `keysSet.length === 0` and the query should be ```sql SELECT "swPublicKey", "swPrivateKey" FROM "meta" where "swPublicKey" IS NOT NULL AND "swPrivateKey" IS NOT NULL ``` Otherwise this doesn't get run and will result in a non-null constraint error.
Owner

Could also be possible to just do

await queryRunner.query(`UPDATE "meta" SET "swPublicKey" = $1, "swPrivateKey" = $2 WHERE "swPublicKey" IS NULL OR "swPrivateKey" IS NULL`, [publicKey, privateKey]);
Could also be possible to just do ```js await queryRunner.query(`UPDATE "meta" SET "swPublicKey" = $1, "swPrivateKey" = $2 WHERE "swPublicKey" IS NULL OR "swPrivateKey" IS NULL`, [publicKey, privateKey]); ```
norm marked this conversation as resolved
Johann150 force-pushed enable-push-notifs from 36c3e1ccc5 to 563f3672a9 2022-11-21 21:01:18 +00:00 Compare
Johann150 added 1 commit 2022-11-21 21:30:46 +00:00
ci/woodpecker/push/lint-foundkey-js Pipeline was successful Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/lint-backend Pipeline was successful Details
ci/woodpecker/push/lint-client Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful Details
ci/woodpecker/pr/lint-backend Pipeline failed Details
ci/woodpecker/pr/build Pipeline was successful Details
ci/woodpecker/pr/lint-client Pipeline failed Details
ci/woodpecker/pr/test Pipeline failed Details
01fa4332c2
server: set vapid keys on initial setup
norm merged commit 973bd4532b into main 2022-11-29 21:51:10 +00:00
norm deleted branch enable-push-notifs 2022-11-29 21:51:11 +00:00
Sign in to join this conversation.
No reviewers
No Label
feature
fix
upkeep
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: FoundKeyGang/FoundKey#235
No description provided.