diff options
| author | Kit La Touche <kit@transneptune.net> | 2025-07-23 17:09:43 -0400 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2025-07-23 17:09:43 -0400 |
| commit | 5e143954c58d2736edd7222cf1befc1aa1025d61 (patch) | |
| tree | aee84db6aeef09a535aa9717a33808cc71c2fc59 | |
| parent | c21eb26c8d011932293aeec3afe4849740f7fdf8 (diff) | |
Get it compiling
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | src/push/handlers/mod.rs | 16 | ||||
| -rw-r--r-- | src/push/handlers/vapid.rs | 0 |
3 files changed, 6 insertions, 12 deletions
@@ -1769,7 +1769,7 @@ version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" dependencies = [ - "bitflags", + "bitflags 2.8.0", "cfg-if", "cfg_aliases", "libc", diff --git a/src/push/handlers/mod.rs b/src/push/handlers/mod.rs index f9ba612..05249c2 100644 --- a/src/push/handlers/mod.rs +++ b/src/push/handlers/mod.rs @@ -9,19 +9,13 @@ use web_push::{ VapidSignatureBuilder, WebPushMessageBuilder, ContentEncoding, + WebPushClient, IsahcWebPushClient, }; -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error(transparent)] - Database(#[from] sqlx::Error), -} - - pub async fn vapid() -> String { - let vapid_public_key = env::var("VAPID_PUBLIC_KEY").is_ok(); + let vapid_public_key = env::var("VAPID_PUBLIC_KEY").unwrap_or_default(); String::from(vapid_public_key) } @@ -39,7 +33,7 @@ pub async fn unregister() -> String { #[axum::debug_handler] pub async fn echo( Json(echo): Json<Echo>, -) -> Result<(), Error> { +) -> Result<(), crate::error::Internal> { // Look this up from a subscription record? Or get it from the client and trust? let endpoint = "https://updates.push.services.mozilla.com/wpush/v1/..."; // Get these from client: @@ -50,8 +44,8 @@ pub async fn echo( let subscription_info = SubscriptionInfo::new(endpoint, p256dh, auth); // This will need to come from the DB eventually. - let private_key = String::from(env::var("VAPID_PRIVATE_KEY").is_ok()); - let mut sig_builder = VapidSignatureBuilder::from_pem(private_key, &subscription_info)?.build()?; + let private_key = String::from(env::var("VAPID_PRIVATE_KEY").unwrap_or_default()); + let sig_builder = VapidSignatureBuilder::from_base64(&private_key, &subscription_info)?.build()?; // Now add payload and encrypt. let mut builder = WebPushMessageBuilder::new(&subscription_info); diff --git a/src/push/handlers/vapid.rs b/src/push/handlers/vapid.rs deleted file mode 100644 index e69de29..0000000 --- a/src/push/handlers/vapid.rs +++ /dev/null |
