[control] Overview for the UI: who is looking (viewer) and the underlying pause reason, so the UI offers the right action
This commit is contained in:
@@ -128,7 +128,11 @@ fn replay(st: &AppState, s: Stored) -> Response {
|
||||
#[utoipa::path(get, path = "/api/v1/overview", tag = "overview",
|
||||
responses((status = 200, body = Overview), (status = 304, description = "Unchanged since the ETag"), (status = 401, body = ErrorEnvelope)),
|
||||
security(("bearer" = [])))]
|
||||
pub async fn overview(State(st): Shared, headers: HeaderMap) -> Result<Response, ApiError> {
|
||||
pub async fn overview(
|
||||
State(st): Shared,
|
||||
Extension(actor): Extension<Actor>,
|
||||
headers: HeaderMap,
|
||||
) -> Result<Response, ApiError> {
|
||||
let c = &st.ctl;
|
||||
let (status, error, since) = {
|
||||
let h = c
|
||||
@@ -227,6 +231,7 @@ pub async fn overview(State(st): Shared, headers: HeaderMap) -> Result<Response,
|
||||
repo: Some(repo_view(c, &head)),
|
||||
intermediate: super::pki::intermediate_view(c),
|
||||
site,
|
||||
paused_reason: c.effective_pause().map(|p| p.code),
|
||||
paused: c.effective_pause().map(|p| {
|
||||
if p.code == "engine.caddy" {
|
||||
Blocked {
|
||||
@@ -251,6 +256,14 @@ pub async fn overview(State(st): Shared, headers: HeaderMap) -> Result<Response,
|
||||
),
|
||||
}),
|
||||
rev: Some(head),
|
||||
viewer: Some(Viewer {
|
||||
via: if actor.token_id.starts_with("user:") {
|
||||
"authelia".into()
|
||||
} else {
|
||||
"token".into()
|
||||
},
|
||||
name: actor.name.clone(),
|
||||
}),
|
||||
};
|
||||
let body = serde_json::to_vec(&ov).map_err(|e| ApiError::internal(e.to_string()))?;
|
||||
let etag = format!("\"{}\"", &sha256_hex(&body)[..32]);
|
||||
|
||||
Reference in New Issue
Block a user