summaryrefslogtreecommitdiff
path: root/src/push
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2025-07-23 17:09:43 -0400
committerKit La Touche <kit@transneptune.net>2025-07-23 17:09:43 -0400
commit5e143954c58d2736edd7222cf1befc1aa1025d61 (patch)
treeaee84db6aeef09a535aa9717a33808cc71c2fc59 /src/push
parentc21eb26c8d011932293aeec3afe4849740f7fdf8 (diff)
Get it compiling
Diffstat (limited to 'src/push')
-rw-r--r--src/push/handlers/mod.rs16
-rw-r--r--src/push/handlers/vapid.rs0
2 files changed, 5 insertions, 11 deletions
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