From 451a85111882ead466382ce8a3b25c8678e8422f Mon Sep 17 00:00:00 2001 From: erio Date: Tue, 3 Mar 2026 07:13:08 +0800 Subject: [PATCH] fix: remove unused sanitizeCustomMenuItemsJSON function Replaced by filterUserVisibleMenuItems which includes both array validation and admin-item filtering. Co-Authored-By: Claude Opus 4.6 --- backend/internal/service/setting_service.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/backend/internal/service/setting_service.go b/backend/internal/service/setting_service.go index a2bb06a4..3809c9d0 100644 --- a/backend/internal/service/setting_service.go +++ b/backend/internal/service/setting_service.go @@ -244,22 +244,6 @@ func (s *SettingService) GetPublicSettingsForInjection(ctx context.Context) (any }, nil } -// sanitizeCustomMenuItemsJSON validates a raw JSON string is a valid JSON array -// and returns it as json.RawMessage. Returns "[]" if the input is empty, not a -// valid JSON array, or is a non-array JSON value (e.g. object, string). -func sanitizeCustomMenuItemsJSON(raw string) json.RawMessage { - raw = strings.TrimSpace(raw) - if raw == "" || raw == "[]" { - return json.RawMessage("[]") - } - // Verify it's actually a JSON array, not an object or other type - var arr []json.RawMessage - if err := json.Unmarshal([]byte(raw), &arr); err != nil { - return json.RawMessage("[]") - } - return json.RawMessage(raw) -} - // filterUserVisibleMenuItems filters out admin-only menu items from a raw JSON // array string, returning only items with visibility != "admin". func filterUserVisibleMenuItems(raw string) json.RawMessage {