modif archi apxtri
This commit is contained in:
@@ -62,7 +62,7 @@ Checkjson.schema.properties.enum = (str, enumvalues) => {
|
||||
//enumvalues is a reference of objectname.key
|
||||
const { tribeId, obj, keyid } = enumvalues.split(".");
|
||||
return fs.existsSync(
|
||||
`../../nationchains/tribes/${tribeId}/schema/${obj}/itm/${keyid}.json`
|
||||
`../../../${tribeId}/schema/${obj}/itm/${keyid}.json`
|
||||
);
|
||||
} else {
|
||||
return true;
|
||||
|
@@ -4,7 +4,7 @@ const glob = require("glob");
|
||||
const jwt = require("jwt-simple");
|
||||
const axios = require("axios");
|
||||
const path = require("path");
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
const Odmdb = require("./Odmdb.js");
|
||||
// lowercase 1st letter is normal
|
||||
const towns = require("./Towns.js");
|
||||
@@ -35,20 +35,20 @@ Nations.updateobjectsfromfreshesttown = (dnstownlist, objectidx) => {
|
||||
* if an item exist localy and does not from the town requested
|
||||
* @Param {array} dnstownlist list of dns to get latest data
|
||||
* @Param {object} objectidx objectnme:idxfile {agans:"alias_all.json",...}
|
||||
* @return create/update nationchains/pagans town nation
|
||||
* @return create/update tribes/adminapi/opjects/pagans town nation
|
||||
*/
|
||||
const localversion = {};
|
||||
const objlist = Object.keys(objectidx);
|
||||
objlist.forEach((o) => {
|
||||
let objconf = {
|
||||
name: o,
|
||||
schema: `../nationchains/tribes/adminapi/schema/${o}.jsons`,
|
||||
schema: `../../schema/${o}.jsons`,
|
||||
lastupdate: -1,
|
||||
};
|
||||
if (fs.existsSync(`../nationchains/${o}/conf.json`)) {
|
||||
objconf = fs.readJsonSync(`../nationchains/${o}/conf.json`);
|
||||
if (fs.existsSync(`../../${o}/conf.json`)) {
|
||||
objconf = fs.readJsonSync(`../../${o}/conf.json`);
|
||||
} else {
|
||||
fs.outputJsonSync(`../nationchains/${o}/conf.json`, objconf);
|
||||
fs.outputJsonSync(`../../${o}/conf.json`, objconf);
|
||||
}
|
||||
localversion[o] = [conf.dns[0], objconf.lastupdate];
|
||||
});
|
||||
@@ -231,7 +231,7 @@ Nations.create = (conf) => {
|
||||
res.info = `your nationId ${conf.nationId} does not exist you have to choose an existing one`;
|
||||
return res;
|
||||
}
|
||||
const towns = fs.readJsonSync("./nationchains/towns/idx/townId_all.json");
|
||||
const towns = fs.readJsonSync("./tribes/adminapi/opjects/towns/idx/townId_all.json");
|
||||
if (towns[conf.nationId].includes(conf.townId)) {
|
||||
res.status = 409;
|
||||
res.info = `This conf.townId already exist you have to find a unique town name`;
|
||||
|
@@ -6,7 +6,7 @@ const dayjs = require("dayjs");
|
||||
const Checkjson = require(`./Checkjson.js`);
|
||||
//const smtp = require("smtp-client");
|
||||
const nodemailer = require("nodemailer");
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
const currentmod = "Notifications";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ const log = conf.api.activelog.includes(currentmod);
|
||||
const Notifications = {};
|
||||
|
||||
Notifications.get = (alias, tribeId) => {
|
||||
const notiffile = `../nationchains/tribes/${req.params.tribeId}/notifications/${req.params.alias}.json`;
|
||||
const notiffile = `../../../${req.params.tribeId}/notifications/${req.params.alias}.json`;
|
||||
const msg = fs.existsSync(notiffile) ? fs.readJSONSync(notiffile) : {};
|
||||
return {
|
||||
status: 200,
|
||||
@@ -43,7 +43,7 @@ Notifications.registertolist = (key, typekey, tribe, mlist, srckey, uuid) => {
|
||||
data: { fielderr: typekey, format: typekey }
|
||||
};
|
||||
|
||||
const destin = `../nationchains/tribes/${tribe}/objects/maillinglists/${typekey}_${mlist}.json`;
|
||||
const destin = `../../../${tribe}/objects/maillinglists/${typekey}_${mlist}.json`;
|
||||
if (!fs.existsSync(destin)){
|
||||
console.log(`######## Attention tentative d'ecriture non autorisé,le fichier n'existe pas ${destin} créer le à la main vide {}`)
|
||||
return {status:406,ref:"Notifications",msg:"destinnotallow",data:{destin}}
|
||||
@@ -69,8 +69,9 @@ Notifications.registertolist = (key, typekey, tribe, mlist, srckey, uuid) => {
|
||||
/**
|
||||
* Unsubscribe an eamil or phone from a mailinglist for a tribe
|
||||
*/
|
||||
Notifications.unsubscribefromlist = (body, header) => {
|
||||
|
||||
Notifications.unregisterfromlist = (key, typekey, tribe,mlist) => {
|
||||
key = key.toLowerCase();
|
||||
|
||||
}
|
||||
/**
|
||||
* Message to send to an alias from an anonymous or not
|
||||
@@ -115,11 +116,11 @@ Notifications.sendsms = async (data, tribeId) => {
|
||||
let confsms = conf.sms;
|
||||
if (
|
||||
fs.existsSync(
|
||||
`../nationchains/tribes/itm/${req.session.header.xtribe}.json`
|
||||
`../../../itm/${req.session.header.xtribe}.json`
|
||||
)
|
||||
) {
|
||||
const conftrib = fs.readJSONSync(
|
||||
`../nationchains/tribes/itm/${req.session.header.xtribe}.json`
|
||||
`../../../itm/${req.session.header.xtribe}.json`
|
||||
);
|
||||
if (conftrib.sms) confsms = conftrib.sms;
|
||||
}
|
||||
@@ -224,7 +225,7 @@ Notifications.sendmail = async (data, tribe) => {
|
||||
};
|
||||
}
|
||||
let confsmtp = conf.smtp;
|
||||
const conftribfile = `../nationchains/tribes/itm/${tribe}.json`;
|
||||
const conftribfile = `../../../itm/${tribe}.json`;
|
||||
if (fs.existsSync(conftribfile)) {
|
||||
const conftrib = fs.readJSONSync(conftribfile);
|
||||
confsmtp = conftrib.smtp;
|
||||
|
@@ -3,7 +3,7 @@ const path = require("path");
|
||||
const fs = require("fs-extra");
|
||||
const dayjs = require("dayjs");
|
||||
const axios = require("axios");
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
const Checkjson = require(`./Checkjson.js`);
|
||||
const { promiseHooks } = require("v8");
|
||||
const currentmod = "Odmdb";
|
||||
@@ -48,7 +48,7 @@ const log = conf.api.activelog.includes(currentmod);
|
||||
const Odmdb = {};
|
||||
|
||||
/**
|
||||
*const Checkjson = require(`../../../../../apxtri/models/Checkjson`);
|
||||
*const Checkjson = require(`../../../adminapi/apxtri/models/Checkjson`);
|
||||
@api syncObject
|
||||
* @param {string} url to an existing object conf (/objectname/conf.json)
|
||||
* @param {timestamp} timestamp
|
||||
@@ -180,7 +180,7 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
|
||||
if (schemaPath.substring(0, 4) == "http") {
|
||||
// lance requete http pour recuperer le schema avec un await axios
|
||||
} else {
|
||||
schemaPath = `../nationchains/tribes/${schemaPath}`;
|
||||
schemaPath = `../../${schemaPath}`;
|
||||
if (log) console.log(currentmod,"resolve path schemaPath:",path.resolve(schemaPath))
|
||||
if (!fs.existsSync(schemaPath)) {
|
||||
return {};
|
||||
@@ -232,7 +232,7 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
|
||||
res.data.schema.properties[p].type == "object" &&
|
||||
res.data.schema.properties[p]["$ref"]
|
||||
) {
|
||||
const subschema = path.resolve(`${objectPathname}/${res.data.schema.properties[p]["$ref"]}`);
|
||||
const subschema = path.resolve(`${objectPathname}/${res.data.schema.properties[p]["$ref"]}.json`);
|
||||
if (Object.keys(res.data.schema).length == 0) {
|
||||
res.status = 404;
|
||||
res.msg = "missingref";
|
||||
@@ -243,13 +243,14 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
|
||||
res.data.schema.properties[p] = subschema;
|
||||
}
|
||||
}
|
||||
//`../../${req.session.header.xtribe}/objects/persons`
|
||||
//looking for options:{"$ref":"../objects/options/xxx.json"}
|
||||
//to add enum:[] = content of options available
|
||||
//to add enum:[] = content of options available in
|
||||
if (
|
||||
res.data.schema.properties[p].options &&
|
||||
res.data.schema.properties[p].options["$ref"]
|
||||
) {
|
||||
const optionsfile = path.resolve(`${objectPathname}/${res.data.schema.properties[p].options["$ref"]}`)
|
||||
const optionsfile = path.resolve(`${objectPathname}/${res.data.schema.properties[p].options["$ref"]}_${lg}.json`)
|
||||
if (log) console.log(currentmod,"Lien vers options:", optionsfile)
|
||||
if (!fs.existsSync(optionsfile)){
|
||||
res.status = 404;
|
||||
@@ -260,7 +261,7 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
|
||||
if (!res.data.schema.apxref) {res.data.schema.apxref=[]}
|
||||
if (!res.data.schema.apxref.includes(res.data.schema.properties[p].options["$ref"]))
|
||||
res.data.schema.apxref.push(res.data.schema.properties[p].options["$ref"])
|
||||
res.data.schema.properties[p].enum=fs.readJSONSync(optionsfile)
|
||||
res.data.schema.properties[p].enum=fs.readJSONSync(optionsfile).lst_idx
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -278,6 +279,7 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
|
||||
if (!res.data.schema.apxuniquekey.includes(res.data.schema.apxid)) {
|
||||
res.data.schema.apxuniquekey.push(res.data.schema.apxid);
|
||||
}
|
||||
//`../../${req.session.header.xtribe}/objects/persons`
|
||||
res.data.schema.apxidx.forEach((idx) => {
|
||||
if (
|
||||
idx.objkey &&
|
||||
@@ -726,15 +728,15 @@ Odmdb.runidx = (objectPathname, schema) => {
|
||||
* @param {object} schema if empty it use schema from Odmdb.Schema().data.schema
|
||||
*
|
||||
* example create alias 12 name fred:
|
||||
* Odmdb.idxfromitm('.../tribes/ndda/persons',"C",{alias:'12',name:"fred"},{},[], {person schema})
|
||||
* Odmdb.idxfromitm('../../../ndda/persons',"C",{alias:'12',name:"fred"},{},[], {person schema})
|
||||
* example update alias 12 in name freddy:
|
||||
* Odmdb.idxfromitm('.../tribes/ndda/persons',"U",{alias:'12',name:"freddy"},{alias:'12',name:"fred"},[], {person schema})
|
||||
* Odmdb.idxfromitm('../../../ndda/persons',"U",{alias:'12',name:"freddy"},{alias:'12',name:"fred"},[], {person schema})
|
||||
* example delete alias 12:
|
||||
* Odmdb.idxfromitm('.../tribes/ndda/persons',"D",{},{alias:'12',name:"fred"},[], {person schema})
|
||||
* Odmdb.idxfromitm('../../../ndda/persons',"D",{},{alias:'12',name:"fred"},[], {person schema})
|
||||
* example to rebuild all index from scratch
|
||||
* Odmdb.idxfromitm('.../tribes/ndda/persons',"I",{},{},[], {person schema})
|
||||
* Odmdb.idxfromitm('../../../ndda/persons',"I",{},{},[], {person schema})
|
||||
* example to rebuild only publickey_alias index from scratch
|
||||
* Odmdb.idxfromitm('.../tribes/ndda/pagans',"I",{},{},[{ name:"publickey_alias",keyval:"publickey",objkey:["alias"]}], {pagans schema})
|
||||
* Odmdb.idxfromitm('../../../ndda/pagans',"I",{},{},[{ name:"publickey_alias",keyval:"publickey",objkey:["alias"]}], {pagans schema})
|
||||
*
|
||||
*/
|
||||
Odmdb.ASUPidxfromitm = (
|
||||
|
@@ -8,7 +8,7 @@ const openpgp = require("openpgp");
|
||||
const Notifications = require("./Notifications.js");
|
||||
const Odmdb = require("./Odmdb.js");
|
||||
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
const currentmod = "Pagans";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
/**
|
||||
@@ -48,13 +48,14 @@ Pagans.logout = (alias, tribe, xdays, xhash) => {
|
||||
**/
|
||||
Pagans.getalias = (alias) => {
|
||||
//bypass Odmdb cause all is public save ressources
|
||||
if (fs.existsSync(`../nationchains/pagans/itm/${alias}.json`)) {
|
||||
console.log(path.resolve(`../objects/pagans/itm/${alias}.json`))
|
||||
if (fs.existsSync(`../objects/pagans/itm/${alias}.json`)) {
|
||||
return {
|
||||
status: 200,
|
||||
ref: "Pagans",
|
||||
msg: "aliasexist",
|
||||
data: fs.readJSONSync(
|
||||
`../nationchains/pagans/itm/${alias}.json`
|
||||
`../objects/pagans/itm/${alias}.json`
|
||||
),
|
||||
};
|
||||
} else {
|
||||
@@ -102,7 +103,7 @@ Pagans.sendmailkey = (data) => {
|
||||
const person = { alias:data.alias, privatekey:data.privatekey, tribe:data.tribe };
|
||||
|
||||
if (!data.publickey || !data.email || !data.privatekey) {
|
||||
const personfile = `../../nationchains/tribes/${data.tribe}/objects/persons/itm/${data.alias}.json`;
|
||||
const personfile = `../../${data.tribe}/objects/persons/itm/${data.alias}.json`;
|
||||
if (!fs.existsSync(personfile)) {
|
||||
return {
|
||||
status: 404,
|
||||
@@ -125,9 +126,9 @@ Pagans.sendmailkey = (data) => {
|
||||
console.log("person:", person);
|
||||
|
||||
|
||||
let tplfile=`../../nationchains/tribes/${data.tribe}/template/createidentity_${data.lg}.js`;
|
||||
let tplfile=`../../../${data.tribe}/template/createidentity_${data.lg}.js`;
|
||||
if (!fs.existsSync(tplfile)){
|
||||
tplfile=`../../nationchains/tribes/adminapi/template/createidentity_${data.lg}.js`;
|
||||
tplfile=`../../../adminapi/template/createidentity_${data.lg}.js`;
|
||||
if (!fs.existsSync(tplfile)){
|
||||
return {
|
||||
status:406,
|
||||
|
@@ -4,7 +4,7 @@ const glob = require("glob");
|
||||
const moment = require("moment");
|
||||
const jwt = require("jwt-simple");
|
||||
const UUID = require("uuid");
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
const Checkjson = require(`./Checkjson.js`);
|
||||
const Odmdb = require("./Odmdb.js");
|
||||
|
||||
@@ -144,7 +144,7 @@ Towns.changeowner = async (newowner, requestby) => {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
if (!fs.existsSync(`./nationchains/pagans/itm/${newowner}.json`)) {
|
||||
if (!fs.existsSync(`./tribes/adminapi/opjects/pagans/itm/${newowner}.json`)) {
|
||||
return {
|
||||
status: 404,
|
||||
ref: "towns",
|
||||
|
@@ -3,7 +3,7 @@ const path = require("path");
|
||||
const fs = require("fs-extra");
|
||||
const dayjs = require("dayjs");
|
||||
const axios = require("axios");
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
const Checkjson = require(`./Checkjson.js`);
|
||||
|
||||
const Trackings = {}
|
||||
|
@@ -10,7 +10,7 @@ const jwt = require( 'jwt-simple' );
|
||||
const moment = require( 'moment' );
|
||||
const UUID = require( 'uuid' );
|
||||
const Pagans = require( './Pagans.js' );
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
const Checkjson = require( `./Checkjson.js`);
|
||||
/*
|
||||
tribeid manager
|
||||
|
@@ -3,7 +3,7 @@ const path = require("path");
|
||||
const dnsSync = require("dns-sync");
|
||||
const mustache = require("mustache");
|
||||
const readlineSync = require("readline-sync");
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
const Wwws = {};
|
||||
|
||||
/*Wwws.apxtriinstall = (paramconf) => {
|
||||
@@ -39,7 +39,7 @@ const Wwws = {};
|
||||
);
|
||||
if (!fs.existsSync(paramconf.nginx.logs)) fs.mkdirSync(paramconf.nginx.logs);
|
||||
paramconf.nginx.firstinstall = true;
|
||||
fs.outputJsonSync("../nationchains/tribes/conf.json", paramconf, {
|
||||
fs.outputJsonSync("../tribes/conf.json", paramconf, {
|
||||
space: 2,
|
||||
});
|
||||
|
||||
|
@@ -3,7 +3,7 @@ Unit testing
|
||||
*/
|
||||
const assert = require("assert");
|
||||
const Checkjson = require("../Checkjson.js");
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
|
||||
const ut = { name: "Checkjson" };
|
||||
|
||||
|
@@ -6,7 +6,7 @@ const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const Odmdb = require("../Odmdb.js");
|
||||
const { generemdp } = require("../toolsbox.js");
|
||||
const conf = require(`../../conf/townconf.json`);
|
||||
const conf = require(`../../../../conf/townconf.json`);
|
||||
|
||||
const ut = { name: "Odmdb" };
|
||||
/*
|
||||
@@ -26,7 +26,7 @@ ut.crud = (objectPathname, itm, profils) => {
|
||||
const testvar={alias:"tutu", passphrase:"",privatekey:"", publickey:""}
|
||||
|
||||
const testitms=[
|
||||
{objectPathname:`../nationchains/pagans`,
|
||||
{objectPathname:`../../../../adminapi/opjects/pagans`,
|
||||
itm:{alias:'toutou', publickey:}}
|
||||
]
|
||||
|
||||
|
Reference in New Issue
Block a user