From b9e31706c33cd5ac10fa66a3a88cb54a5327220c Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Fri, 20 Jun 2025 15:40:04 +0000
Subject: [PATCH] GS-2156

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

diff --git a/lib/libIlias.js b/lib/libIlias.js
index 5dd90ab..b261889 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")
@@ -59,29 +60,29 @@
    })
    let url2 = `${url}?${sp.toString()}`
    console.log(url2)
+
+   console.log(user)
+   const udfDef = await db.getUdf()
+   const udfMap = _.keyBy(udfDef, "field_name")
+   user.udf = _.mapKeys(user.udf, function (value, key) {
+      return udfMap[key].field_id
+   })
+   console.log(user)
+   // return "jo"
+
    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