From ed5e175a806f45469a6e5504ba0d3f5246997fad Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Wed, 30 Jul 2025 23:08:40 -0400 Subject: Test receiving push events when backgrounded And thus also displaying notifications. --- src/push/handlers/echo.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/push/handlers/echo.rs') diff --git a/src/push/handlers/echo.rs b/src/push/handlers/echo.rs index 4b4de57..a6c7be2 100644 --- a/src/push/handlers/echo.rs +++ b/src/push/handlers/echo.rs @@ -1,10 +1,10 @@ use axum::extract::{Json, State}; -use crate::{app::App, push::Id, token::extract::Identity}; +use crate::{app::App, token::extract::Identity}; #[derive(serde::Deserialize)] pub struct Request { - subscription: Id, + endpoint: String, msg: String, } @@ -13,8 +13,18 @@ pub async fn handler( identity: Identity, Json(request): Json, ) -> Result<(), crate::error::Internal> { - let Request { subscription, msg } = request; - app.push().echo(&identity.user, &subscription, &msg).await?; + let Request { endpoint, msg } = request; + app.push().echo(&identity.user, &endpoint, &msg).await?; + + Ok(()) +} + +pub async fn broadcast( + State(app): State, + Json(request): Json, +) -> Result<(), crate::error::Internal> { + let Request { endpoint: _, msg } = request; + app.push().broadcast(&msg).await?; Ok(()) } -- cgit v1.2.3