From eed6ccf2a6000f9b0c504dd2b6da9cdee6221e37 Mon Sep 17 00:00:00 2001
From: Linventif <gregoire.becue@proton.me>
Date: Fri, 16 Aug 2024 15:13:09 +0000
Subject: [PATCH] Fix: hide /bugs screenshots

---
 lua/gmod_integration/shared/sh_http.lua | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lua/gmod_integration/shared/sh_http.lua b/lua/gmod_integration/shared/sh_http.lua
index e485029..a7d6cc5 100644
--- a/lua/gmod_integration/shared/sh_http.lua
+++ b/lua/gmod_integration/shared/sh_http.lua
@@ -7,9 +7,13 @@ local function getAPIURL(endpoint)
     return method .. "://" .. gmInte.config.apiFQDN .. "/" .. apiVersion .. endpoint
 end
 
-local function showableBody(endpoint)
-    if string.sub(endpoint, 1, 8) == "/streams" || string.sub(endpoint, 1, 12) == "/screenshots" then return false end
-    return true
+local function showableBody(endpoint, body)
+    if endpoint == "/clients/:steamID64/servers/:serverID/screenshots" then
+        body.screenshot = "[IMAGE DATA]"
+    elseif endpoint == "/clients/:steamID64/servers/:serverID/bugs" then
+        body.screenshot.screenshot = "[IMAGE DATA]"
+    end
+    return util.TableToJSON(body || {})
 end
 
 function gmInte.http.requestAPI(params)
@@ -39,7 +43,7 @@ function gmInte.http.requestAPI(params)
     gmInte.log("HTTP FQDN: " .. gmInte.config.apiFQDN, true)
     gmInte.log("HTTP Request ID: " .. localRequestID, true)
     gmInte.log("HTTP Request: " .. method .. " " .. url, true)
-    gmInte.log("HTTP Body: " .. (showableBody(params.endpoint) && body || "HIDDEN"), true)
+    gmInte.log("HTTP Body: " .. showableBody(params.endpoint, params.body), true)
     HTTP({
         ["url"] = url,
         ["method"] = method,