REST Service for POPCORN - ILIAS
alex
2025-06-16 94fc1d0d195e86785b9342eebc2dcf7897108d55
lib/libIlias.js
@@ -2,11 +2,13 @@
module.exports = {
   deleteUser,
   deleteTeilnahme,
}
/////////////////////////////////////////////////////////////////////////
const settings = require("../settings")
const {getObjIdFromRefId} = require("./db")
const {url} = settings.ilias
/////////////////////////////////////////////////////////////////////////
@@ -15,12 +17,31 @@
   const sp = new URLSearchParams({
      command: "deleteUser",
      obj_id,
      dry : dry ? "1" : "0",
      // dry: "1",
      dry: dry ? "1" : "0",
   })
   let url2 = `${url}?${sp.toString()}`
   console.log("libIlias.deleteUser >>>", url2)
   const res = await fetch(url2, {method: "DELETE"})
   // console.log(res)
   const data = await res.json()
   return data
}
async function deleteTeilnahme (ref_id, usr_id, dry = false) {
   const {obj_id} = await getObjIdFromRefId(ref_id)
   const sp = new URLSearchParams({
      command: "deleteTeilnahme",
      obj_id,
      usr_id,
      dry: dry ? "1" : "0",
   })
   let url2 = `${url}?${sp.toString()}`
   console.log("libIlias.deleteTeilnahme >>>", url2)
   let res
   try {
      res = await fetch(url2, {method: "DELETE"})
      return await res.json()
   } catch (ex) {
      console.error(ex)
      throw ex
   }
}