From 2920ccfa508fe5e8c32905fe102758b65fb37574 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Thu, 08 Oct 2026 16:42:29 +0000
Subject: [PATCH] GS-2555
---
lib/libIlias.js | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/lib/libIlias.js b/lib/libIlias.js
index 4d8e7c2..1b5630d 100644
--- a/lib/libIlias.js
+++ b/lib/libIlias.js
@@ -5,10 +5,13 @@
const db = require("./db")
const {url, iliastoken} = settings.ilias
const search = require("./search")
+const log = require("../logger")
/////////////////////////////////////////////////////////////////////////
module.exports = {
+ ping,
+
getUser,
importIliasUser,
@@ -26,6 +29,17 @@
}
/////////////////////////////////////////////////////////////////////////
+
+async function ping() {
+ const sp = new URLSearchParams({
+ command: "ping",
+ token: iliastoken,
+ })
+ let url2 = `${url}?${sp.toString()}`
+ log.debug("pinging url", url2)
+ const res = await fetch(url2, {method: "GET"})
+ return await res.json() //
+}
/////// GET USER ////////////////////////////////////////////////////////////////
async function getUser (usr_id) {
@@ -72,13 +86,16 @@
const udfDef = await db.getUdf()
const udfMap = _.keyBy(udfDef, "field_name")
- 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 {
@@ -176,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()
}
@@ -189,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