Fixed notifications VAPID
Build and Publish / Build and Publish Docker Image (push) Successful in 1m26s

This commit is contained in:
Ultradesu
2026-08-08 11:21:23 +01:00
parent 289b1e8d37
commit d6e6075469
6 changed files with 105 additions and 24 deletions
+13 -1
View File
@@ -507,6 +507,7 @@ async fn portal_push_subscribe(
db: Database,
Path(token): Path<String>,
) -> cot::Result<Response> {
tracing::info!("client Web Push subscription request");
if crate::web_push::load_config(&db).await.is_none() {
return Html::new("404").into_response();
}
@@ -522,8 +523,19 @@ async fn portal_push_subscribe(
|| form.keys.p256dh.len() > 512
|| form.keys.auth.len() > 256
{
return Html::new("400").into_response();
let mut response = Response::new(cot::Body::fixed(
"{\"ok\":false,\"error\":\"invalid subscription\"}",
));
*response.status_mut() = cot::StatusCode::BAD_REQUEST;
response
.headers_mut()
.insert("content-type", "application/json".parse().unwrap());
return Ok(response);
}
tracing::info!(
client_id = client.id.unwrap(),
"client Web Push subscription saved"
);
let endpoint = form.endpoint.clone();
let now = chrono::Utc::now().naive_utc();
if let Some(mut subscription) = query!(PushSubscription, $endpoint == endpoint)