From 6138ffe99d016cc311f250bc1555b5403b8b1216 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Thu, 08 Oct 2026 17:18:04 +0000
Subject: [PATCH] GS-2555

---
 lib/libIlias.js |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/libIlias.js b/lib/libIlias.js
index 180fb45..1b5630d 100644
--- a/lib/libIlias.js
+++ b/lib/libIlias.js
@@ -5,6 +5,7 @@
 const db = require("./db")
 const {url, iliastoken} = settings.ilias
 const search = require("./search")
+const log = require("../logger")
 
 /////////////////////////////////////////////////////////////////////////
 
@@ -35,7 +36,7 @@
       token: iliastoken,
    })
    let url2 = `${url}?${sp.toString()}`
-   console.log("pinging url", url2)
+   log.debug("pinging url", url2)
    const res = await fetch(url2, {method: "GET"})
    return await res.json() //
 }
@@ -85,14 +86,16 @@
 
    const udfDef = await db.getUdf()
    const udfMap = _.keyBy(udfDef, "field_name")
-   // console.dir(udfMap, {depth: null, colors: true, maxArrayLength: null})
-   user.udf = _.mapKeys(user.udf, function (value, key) {
+
+   // do not mutate the caller's user object
+   const user2 = _.cloneDeep(user)
+   user2.udf = _.mapKeys(user.udf, function (value, key) {
       return udfMap[key].field_id
    })
 
    const res = await fetch(url2, {
       method: "POST",
-      body: JSON.stringify(user)
+      body: JSON.stringify(user2)
    })
    const text = await res.text()
    try {
@@ -190,7 +193,7 @@
       token: iliastoken,
    })
    let url2 = `${url}?${sp.toString()}`
-   console.log(url2)
+   log.debug(url2)
    const res = await fetch(url2, {method: "POST"})
    return await res.json()
 }
@@ -203,7 +206,7 @@
       token: iliastoken,
    })
    let url2 = `${url}?${sp.toString()}`
-   console.log(url2)
+   log.debug(url2)
    const res = await fetch(url2, {method: "DELETE"})
    return await res.json()
 }

--
Gitblit v1.8.0