modif pour image
This commit is contained in:
@@ -338,6 +338,16 @@ Odmdb.Schema = (objectPathname, validschema, lg = "en") => {
|
||||
}
|
||||
if (res.data.schema.apxidx) {
|
||||
//add apxidx to apxuniquekey in case not
|
||||
|
||||
if (!res.data.schema.apxuniquekey) {
|
||||
return {
|
||||
status: 406,
|
||||
ref: "Odmdb",
|
||||
msg: "missingapxuniquekey",
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
|
||||
if (!res.data.schema.apxuniquekey.includes(res.data.schema.apxid)) {
|
||||
res.data.schema.apxuniquekey.push(res.data.schema.apxid);
|
||||
}
|
||||
@@ -639,7 +649,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
}
|
||||
if (!existid && ["U", "D"].includes(crud)) {
|
||||
return {
|
||||
status: 406,
|
||||
status: 404,
|
||||
ref: "Odmdb",
|
||||
msg: "doesnotexist",
|
||||
data: {
|
||||
@@ -668,7 +678,12 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
getschema.data.schema.apxaccessrights,
|
||||
role
|
||||
);
|
||||
|
||||
if (log) console.log(currentmod, "Accessright to: ", accessright);
|
||||
if (getschema.data.schema.apxaccessrights.contextrules) {
|
||||
//Need to check context to validate accessright
|
||||
//require('../../')
|
||||
}
|
||||
if (
|
||||
(crud == "C" && !accessright.C) ||
|
||||
(crud == "D" && !accessright.D) ||
|
||||
@@ -683,6 +698,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
};
|
||||
}
|
||||
//delete or save
|
||||
|
||||
if (crud == "D") {
|
||||
itmold["dt_delete"] = dayjs().toISOString();
|
||||
fs.outputJSONSync(
|
||||
@@ -703,11 +719,38 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
if (keynotallow.length > 0) {
|
||||
feedbackinfo.keynotallow = keynotallow;
|
||||
}
|
||||
accessright.U.forEach((p) => {
|
||||
accessright.U.forEach(async (p) => {
|
||||
itmtostore[p] = itm[p];
|
||||
});
|
||||
itmtostore.dt_update = dayjs().toISOString();
|
||||
}
|
||||
Object.keys(itmtostore).forEach((k) => {
|
||||
//Manage base64 case image to convert ans store in webp
|
||||
if (k.includes("imgbase64_") && itmtostore[k] != "") {
|
||||
fs.ensureDirSync(`${objectPathname}/img/`);
|
||||
const imgb64 = itmtostore[k];
|
||||
const extension = imgb64.split(";base64,")[0].split("/")[1];
|
||||
const newk = k.split("_").slice(1).join("_");
|
||||
const filenameimg = `/img/${
|
||||
itmtostore[getschema.data.schema.apxid]
|
||||
}_${newk}.${extension}`;
|
||||
if (!getschema.data.schema.properties[newk]) {
|
||||
if (log)
|
||||
console.log(
|
||||
currentmod,
|
||||
" Check your schema it miss a propertie because imgbase64_blabla must have a blabla propertie to host the pathfile image"
|
||||
);
|
||||
} else {
|
||||
const objectname = objectPathname.split("/").slice(-1)[0];
|
||||
itmtostore[newk] = `${objectname}/${filenameimg}`;
|
||||
//const webp = require("webp-converter");
|
||||
const buf = Buffer.from(itmtostore[k], 'base64');
|
||||
//const imgwebp = await webp.bufferToWebp(buf);
|
||||
fs.writeFileSync(`${objectPathname}/${filenameimg}`, buf);
|
||||
itmtostore[k] = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
if (crud == "C") itmtostore.dt_create = dayjs().toISOString();
|
||||
// check consistency of datatostore
|
||||
const chkdata = Checkjson.schema.data(
|
||||
|
@@ -112,6 +112,14 @@ Pagans.sendmailkey = (data) => {
|
||||
data: { alias:data.alias, tribe:data.tribe },
|
||||
};
|
||||
}
|
||||
if (!persondata.recoveryauth){
|
||||
return {
|
||||
status:404,
|
||||
ref:"Pagans",
|
||||
msg:"personhasnorecoveryauth",
|
||||
data:{alias:data.alias, tribe:data.tribe,email:data.email}
|
||||
}
|
||||
}
|
||||
const persondata= fs.readJsonSync(personfile);
|
||||
person.email = persondata.recoveryauth.email;
|
||||
person.publickey = persondata.recoveryauth.publickey;
|
||||
|
Reference in New Issue
Block a user