From edcd171ffd7454e0643d525758630218c6d2f8d6 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Sun, 22 Jun 2025 09:09:03 +0000
Subject: [PATCH] GS-2156

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

diff --git a/lib/libIlias.js b/lib/libIlias.js
index 5dd90ab..5fbab40 100644
--- a/lib/libIlias.js
+++ b/lib/libIlias.js
@@ -1,4 +1,5 @@
 /* Lib for interacting with customized ILIAS php */
+const _ = require("lodash")
 const settings = require("../settings")
 const {getObjIdFromRefId} = require("./db")
 const db = require("./db")
@@ -58,30 +59,24 @@
       token: iliastoken,
    })
    let url2 = `${url}?${sp.toString()}`
-   console.log(url2)
+
+   const udfDef = await db.getUdf()
+   const udfMap = _.keyBy(udfDef, "field_name")
+   user.udf = _.mapKeys(user.udf, function (value, key) {
+      return udfMap[key].field_id
+   })
+
    const res = await fetch(url2, {
       method: "POST",
       body: JSON.stringify(user)
    })
-
-   // const data = await res.json()
-   // return data
-
    const text = await res.text()
    try {
-      const json = JSON.parse(text)
-      return json
+      return JSON.parse(text)
    } catch (ex) {
       console.error(ex.message)
       console.log(text)
       throw ex
-   }
-   try {
-      return data
-   } catch (ex) {
-      const text = await res.text()
-      console.error(text)
-      return false
    }
 }
 

--
Gitblit v1.8.0