From 39282cf5d9494290a674a01a3f1f8172badcb16e Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Sun, 3 Aug 2025 23:19:32 -0400 Subject: Remove echo and broadcast web-push logic They were just there for hand-testing. We don't want them in the final server. --- src/push/app.rs | 47 ----------------------------------------------- src/push/handlers/mod.rs | 3 --- src/routes.rs | 4 +--- 3 files changed, 1 insertion(+), 53 deletions(-) (limited to 'src') diff --git a/src/push/app.rs b/src/push/app.rs index ed8bf31..d16267a 100644 --- a/src/push/app.rs +++ b/src/push/app.rs @@ -46,53 +46,6 @@ impl<'a> Push<'a> { Ok(id) } - pub async fn broadcast( - &self, - message: &str, - ) -> Result<(), EchoError> { - let mut tx = self.db.begin().await?; - let subscriptions = tx - .subscriptions() - .all() - .await?; - - tx.commit().await?; - - for subscription in subscriptions { - // We don't care if any of these error, for now. - // Eventually, we should remove rows that cause certain error conditions. - println!("Sending to {:#?}", subscription.info.endpoint); - self.send(&subscription.info, message).await.unwrap_or_else(|err| { - println!("Error with {:#?}: {}", subscription.info.endpoint, err); - }) - } - - Ok(()) - } - - pub async fn echo( - &self, - user: &User, - endpoint: &String, - message: &str, - ) -> Result<(), EchoError> { - let mut tx = self.db.begin().await?; - let subscription = tx - .subscriptions() - .by_endpoint(endpoint) - .await - .not_found(|| EchoError::NotFound(endpoint.clone()))?; - if subscription.user != user.id { - return Err(EchoError::NotSubscriber(subscription.id, user.id.clone())); - } - - tx.commit().await?; - - self.send(&subscription.info, message).await?; - - Ok(()) - } - async fn send(&self, subscription: &SubscriptionInfo, message: &str) -> Result<(), EchoError> { let sig_builder = self .vapid_signer diff --git a/src/push/handlers/mod.rs b/src/push/handlers/mod.rs index 4b27ff5..14549cb 100644 --- a/src/push/handlers/mod.rs +++ b/src/push/handlers/mod.rs @@ -2,12 +2,9 @@ use axum::extract::State; use crate::app::App; -mod echo; mod register; mod unregister; -pub use echo::handler as echo; -pub use echo::broadcast as broadcast; pub use register::handler as register; pub use unregister::handler as unregister; diff --git a/src/routes.rs b/src/routes.rs index 3e2fc04..3180afa 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -27,9 +27,7 @@ pub fn routes(app: &App) -> Router { .route("/api/setup", post(setup::handlers::setup)) .route("/api/vapid", get(push::handlers::vapid)) .route("/api/push", post(push::handlers::register)) - .route("/api/push", delete(push::handlers::unregister)) - .route("/api/broadcast", post(push::handlers::broadcast)) - .route("/api/echo", post(push::handlers::echo)); + .route("/api/push", delete(push::handlers::unregister)); // API routes that require the administrator to complete setup first. let api_setup_required = Router::new() -- cgit v1.2.3