summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2025-08-03 23:19:32 -0400
committerKit La Touche <kit@transneptune.net>2025-08-03 23:19:32 -0400
commit39282cf5d9494290a674a01a3f1f8172badcb16e (patch)
tree598423e56786d4d05af3121d2334014a39166e3c /src
parenteaf95ece7dfb4d4d591b2f501183b2706653742e (diff)
Remove echo and broadcast web-push logic
They were just there for hand-testing. We don't want them in the final server.
Diffstat (limited to 'src')
-rw-r--r--src/push/app.rs47
-rw-r--r--src/push/handlers/mod.rs3
-rw-r--r--src/routes.rs4
3 files changed, 1 insertions, 53 deletions
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<App> {
.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()