REST Service for POPCORN - ILIAS
alex
2025-06-18 a845b328e326fc8c827ca43fafd43e8c39640275
lib/libIlias.js
@@ -2,6 +2,7 @@
module.exports = {
   deleteUser,
   deleteAllUsers,
   deleteTeilnahme,
}
@@ -9,7 +10,8 @@
const settings = require("../settings")
const {getObjIdFromRefId} = require("./db")
const {url} = settings.ilias
const db = require("./db")
const {url, iliastoken} = settings.ilias
/////////////////////////////////////////////////////////////////////////
@@ -17,12 +19,36 @@
   const sp = new URLSearchParams({
      command: "deleteUser",
      obj_id,
      // dry: "1",
      dry: dry ? "1" : "0",
      token: iliastoken,
   })
   let url2 = `${url}?${sp.toString()}`
   console.log("libIlias.deleteUser >>>", url2)
   const res = await fetch(url2, {method: "DELETE"})
   return await res.json()
   const data = await res.json()
   // TODO update search index
   return data //
}
async function deleteAllUsers () {
   const {data: users} = await db.getUsers(0, 100000)
   const res = {
      command: "deleteAllUsers",
      start: new Date(),
      end: new Date(),
      duration: null,
      count: 0,
      userIds: [],
   }
   for (const user of users) {
      await deleteUser(user.usr_id)
      res.count += 1
      res.userIds.push(user.usr_id)
   }
   res.end = new Date()
   res.duration = res.end - res.start
   // TODO update search index
   return res
}
async function deleteTeilnahme (ref_id, usr_id, dry = false) {
@@ -32,6 +58,7 @@
      obj_id,
      usr_id,
      dry: dry ? "1" : "0",
      token: iliastoken,
   })
   let url2 = `${url}?${sp.toString()}`
   console.log("libIlias.deleteTeilnahme >>>", url2)