From 2ccd5167d93f96f7c10c8e673f9eae6c64a6658f Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Wed, 20 Apr 2022 12:14:06 +0000 Subject: [PATCH] :wrench: allow hiding the audit log on the relay --- crates/ptth_relay/src/config.rs | 4 ++++ crates/ptth_relay/src/lib.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/crates/ptth_relay/src/config.rs b/crates/ptth_relay/src/config.rs index f28d172..0865ec4 100644 --- a/crates/ptth_relay/src/config.rs +++ b/crates/ptth_relay/src/config.rs @@ -143,6 +143,7 @@ pub mod file { pub scraper_keys: Option >, pub news_url: Option , + pub hide_audit_log: Option , } } @@ -156,6 +157,7 @@ pub struct Config { pub servers: HashMap , pub scraper_keys: HashMap , pub news_url: Option , + pub hide_audit_log: bool, } impl Default for Config { @@ -167,6 +169,7 @@ impl Default for Config { servers: Default::default (), scraper_keys: Default::default (), news_url: None, + hide_audit_log: false, } } } @@ -195,6 +198,7 @@ impl TryFrom for Config { servers, scraper_keys, news_url: f.news_url, + hide_audit_log: f.hide_audit_log.unwrap_or (false), }) } } diff --git a/crates/ptth_relay/src/lib.rs b/crates/ptth_relay/src/lib.rs index 72c5f9d..f489a17 100644 --- a/crates/ptth_relay/src/lib.rs +++ b/crates/ptth_relay/src/lib.rs @@ -433,6 +433,13 @@ async fn handle_audit_log ( handlebars: Arc > ) -> Result , RequestError> { + { + let cfg = state.config.read ().await; + if cfg.hide_audit_log { + return Ok (error_reply (StatusCode::FORBIDDEN, "Forbidden")?); + } + } + let page = handle_audit_log_internal (state).await; let s = handlebars.render ("audit_log", &page)?;