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 |   36 ++++++++++++++++--------------------
 1 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/lib/libIlias.js b/lib/libIlias.js
index 1016beb..5fbab40 100644
--- a/lib/libIlias.js
+++ b/lib/libIlias.js
@@ -1,4 +1,12 @@
 /* Lib for interacting with customized ILIAS php */
+const _ = require("lodash")
+const settings = require("../settings")
+const {getObjIdFromRefId} = require("./db")
+const db = require("./db")
+const {url, iliastoken} = settings.ilias
+const search = require("./search")
+
+/////////////////////////////////////////////////////////////////////////
 
 module.exports = {
    importIliasUser,
@@ -10,12 +18,6 @@
 
 /////////////////////////////////////////////////////////////////////////
 
-const settings = require("../settings")
-const {getObjIdFromRefId} = require("./db")
-const db = require("./db")
-const {url, iliastoken} = settings.ilias
-
-/////////////////////////////////////////////////////////////////////////
 
 /////// USER IMPORT ////////////////////////////////////////////////////////////////
 
@@ -57,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