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.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/push/handlers/echo.rs b/src/push/handlers/echo.rs
new file mode 100644
index 0000000..4b4de57
--- /dev/null
+++ b/src/push/handlers/echo.rs
@@ -0,0 +1,20 @@
+use axum::extract::{Json, State};
+
+use crate::{app::App, push::Id, token::extract::Identity};
+
+#[derive(serde::Deserialize)]
+pub struct Request {
+ subscription: Id,
+ msg: String,
+}
+
+pub async fn handler(
+ State(app): State<App>,
+ identity: Identity,
+ Json(request): Json<Request>,
+) -> Result<(), crate::error::Internal> {
+ let Request { subscription, msg } = request;
+ app.push().echo(&identity.user, &subscription, &msg).await?;
+
+ Ok(())
+}