From ebe744f1364306c2a462d03cc1681a24ab7dfe56 Mon Sep 17 00:00:00 2001 From: Ben Brooks Date: Tue, 25 Jun 2024 20:27:06 +0100 Subject: [PATCH] Show correct 'enabled' state for event in /db/_config/audit --- rest/admin_api.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rest/admin_api.go b/rest/admin_api.go index f492294f27..8b3a7fe457 100644 --- a/rest/admin_api.go +++ b/rest/admin_api.go @@ -673,6 +673,11 @@ func (h *handler) handleGetDbAuditConfig() error { showOnlyFilterable := h.getBoolQuery("filterable") verbose := h.getBoolQuery("verbose") + isEnabledFn := func(id base.AuditID) bool { + _, ok := h.db.Options.LoggingConfig.Audit.EnabledEvents[id] + return ok + } + // TODO: Move to structs events := make(map[string]interface{}, len(base.AuditEvents)) for id, descriptor := range base.AuditEvents { @@ -684,11 +689,11 @@ func (h *handler) handleGetDbAuditConfig() error { events[idStr] = map[string]interface{}{ "name": descriptor.Name, "description": descriptor.Description, - "enabled": descriptor.EnabledByDefault, // TODO: Switch to actual configuration + "enabled": isEnabledFn(id), "filterable": descriptor.FilteringPermitted, } } else { - events[idStr] = descriptor.EnabledByDefault // TODO: Switch to actual configuration + events[idStr] = isEnabledFn(id) } }