mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Add a GET /api/config endpoint exposing the front-end-facing backend
configuration (currently the notification delivery method, grouped under
a nested "notifications" object so the shape can grow). The settings
screen fetches it on init and only shows the per-device push toggle when
the backend method is "push" (and the platform supports push, which keeps
it off the browser).
Also fold in related push-notifications cleanups: fix the Android app
label ("frontend" -> "OOTT") so the notification permission dialog reads
correctly, remove the completed push_notifications.md plan, and update
TODO.md.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
987 B
Rust
42 lines
987 B
Rust
use axum::Json;
|
|
|
|
use crate::model::config::{Config, NotificationConfig};
|
|
use crate::settings::get_settings;
|
|
|
|
#[utoipa::path(
|
|
get,
|
|
path = "/api/config",
|
|
tag = "config",
|
|
responses(
|
|
(status = 200, description = "Front-end configuration", body = Config),
|
|
),
|
|
security(("bearer_auth" = []))
|
|
)]
|
|
pub async fn read() -> Json<Config> {
|
|
let settings = get_settings();
|
|
Json(Config {
|
|
notifications: NotificationConfig {
|
|
method: settings.notifications.method.clone(),
|
|
},
|
|
})
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use crate::tests_common;
|
|
|
|
#[tokio::test]
|
|
async fn config_reports_the_configured_notification_method() {
|
|
tests_common::setup().await;
|
|
|
|
let Json(config) = read().await;
|
|
|
|
assert_eq!(
|
|
config.notifications.method,
|
|
get_settings().notifications.method,
|
|
"The endpoint should echo the backend's configured notification method"
|
|
);
|
|
}
|
|
}
|