fix boolean update odmdb

This commit is contained in:
philc 2025-03-27 12:14:59 +01:00
parent 57d7301800
commit 38587df7e9
4 changed files with 22 additions and 10 deletions

@ -297,9 +297,8 @@ Notifications.manageemail = async (
} }
emailtosend.to = ""; emailtosend.to = "";
email.to.forEach((em) => { email.to.forEach((em) => {
em = em.toLowerCase().trim(); if (typeof em === "string" && Checkjson.testformat(em, "email")) {
if (Checkjson.testformat(em, "email")) { emailtosend.to += em.toLowerCase().trim() + ",";
emailtosend.to += em + ",";
} else { } else {
results.fail.push({ to: em, err: ["errorformat"] }); results.fail.push({ to: em, err: ["errorformat"] });
} }

@ -656,14 +656,27 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
//console.log('itmstore',itmtostore) //console.log('itmstore',itmtostore)
//console.log("itm",itm) //console.log("itm",itm)
//console.log(accessright) //console.log(accessright)
accessright.U.forEach(async (p) => { /*accessright.U.forEach(async (p) => {
// check this propertie exist in the requested update itm // check this propertie exist in the requested update itm
const testvaliditmupdate = const testvaliditmupdate =
itm[p] === 0 || itm[p] === 0 || itm[p] === true || itm[p]=== false ||
(itm[p] && (itm[p] &&
((typeof itm[p] === "string" && itm[p].trim() !== "") || ((typeof itm[p] === "string" && itm[p].trim() !== "") ||
typeof itm[p] !== "string")); typeof itm[p] !== "string"));
if (testvaliditmupdate) itmtostore[p] = itm[p]; if (testvaliditmupdate) itmtostore[p] = itm[p];
});*/
accessright.U.forEach(async (p) => {
if (itm[p] === 0 || itm[p] === false || itm[p] === true) {
// Cas numéro 0 ou booléens
itmtostore[p] = itm[p];
} else if (itm[p]) {
// Cas non-vide (autres types)
if (typeof itm[p] === "string") {
if (itm[p].trim() !== "") itmtostore[p] = itm[p]; // String non vide
} else {
itmtostore[p] = itm[p]; // Autres types (objets, nombres, etc.)
}
}
}); });
itmtostore.dt_update = dayjs().toISOString(); itmtostore.dt_update = dayjs().toISOString();
} }

@ -9,7 +9,7 @@ const Articles = require(`../models/Articles`);
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`); const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
const currentmod = "Articles"; const currentmod = "Articles";
const log = conftrib.activelog.includes(currentmod); const log = conf.api.activelog.includes(currentmod);
const router = express.Router(); const router = express.Router();

@ -54,11 +54,13 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@tailwindcss/typography": "^0.5.15",
"apidoc": "^1.2.0", "apidoc": "^1.2.0",
"async": "^3.2.0", "async": "^3.2.0",
"axios": "^1.7.8", "axios": "^1.7.8",
"bcrypt": "^5.0.0", "bcrypt": "^5.0.0",
"cors": "^2.8.4", "cors": "^2.8.4",
"daisyui": "^5.0.9",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"dns-sync": "^0.2.1", "dns-sync": "^0.2.1",
"express": "^4.21.1", "express": "^4.21.1",
@ -78,10 +80,8 @@
"sharp": "^0.33.5", "sharp": "^0.33.5",
"smtp-client": "^0.4.0", "smtp-client": "^0.4.0",
"stripe": "^17.3.1", "stripe": "^17.3.1",
"uuid": "^11.0.2", "tailwindcss": "^4.0.15",
"@tailwindcss/typography": "^0.5.15", "uuid": "^11.0.2"
"daisyui": "^4.12.23",
"tailwindcss": "^3.4.17"
}, },
"devDependencies": {} "devDependencies": {}
} }