summaryrefslogtreecommitdiff
path: root/src/push/handlers/echo.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/push/handlers/echo.rs')
-rw-r--r--src/push/handlers/echo.rs18
1 files changed, 14 insertions, 4 deletions
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<Request>,
) -> 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<App>,
+ Json(request): Json<Request>,
+) -> Result<(), crate::error::Internal> {
+ let Request { endpoint: _, msg } = request;
+ app.push().broadcast(&msg).await?;
Ok(())
}