modif notification email
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -18,6 +18,4 @@
|
|||||||
!objects/
|
!objects/
|
||||||
!objects/options/
|
!objects/options/
|
||||||
!objects/options/**
|
!objects/options/**
|
||||||
!objects/tplstrings/
|
|
||||||
!objects/tplstrings/**
|
|
||||||
|
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
|||||||
if (!doms.includes(dm)) doms.push(dm);
|
if (!doms.includes(dm)) doms.push(dm);
|
||||||
//reindex database attention check dev-ants/.. a bug was fixed
|
//reindex database attention check dev-ants/.. a bug was fixed
|
||||||
glob.sync(`../${t}/objects/*`).forEach((o) => {
|
glob.sync(`../${t}/objects/*`).forEach((o) => {
|
||||||
//console.log("reindex: ", o);
|
console.log("reindex: ", o);
|
||||||
Odmdb.runidx(o);
|
Odmdb.runidx(o);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -242,7 +242,7 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
|||||||
context.routes.push(rt);
|
context.routes.push(rt);
|
||||||
return { url: rt, route: f };
|
return { url: rt, route: f };
|
||||||
});
|
});
|
||||||
context.models = glob.sync(`${pathtr}/apxtri/models/*.js`).map((f) => {
|
/* context.models = glob.sync(`${pathtr}/apxtri/models/*.js`).map((f) => {
|
||||||
const modname = `${path.basename(f, ".js")}`;
|
const modname = `${path.basename(f, ".js")}`;
|
||||||
return {
|
return {
|
||||||
model: modname,
|
model: modname,
|
||||||
@@ -251,6 +251,7 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
|||||||
.map((l) => path.basename(l, ".json").split("_")[1]),
|
.map((l) => path.basename(l, ".json").split("_")[1]),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
//console.log(context.routes);
|
//console.log(context.routes);
|
||||||
//console.log(context.models);
|
//console.log(context.models);
|
||||||
//const conft = `../itm/${t}.json`;
|
//const conft = `../itm/${t}.json`;
|
||||||
@@ -274,8 +275,8 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
|||||||
app.disable("x-powered-by"); // for security
|
app.disable("x-powered-by"); // for security
|
||||||
app.locals.tribeids = tribeIds;
|
app.locals.tribeids = tribeIds;
|
||||||
const currentmod = "apxtri";
|
const currentmod = "apxtri";
|
||||||
const log = conf.api.activelog
|
const log = process.env.ACTIVELOG.split(',')
|
||||||
? conf.api.activelog.includes(currentmod)
|
? process.env.ACTIVELOG.split(',').includes(currentmod)
|
||||||
: false;
|
: false;
|
||||||
console.log(
|
console.log(
|
||||||
currentmod,
|
currentmod,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const path=require('path')
|
const path=require('path')
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod='checkHeaders';
|
const currentmod='checkHeaders';
|
||||||
const log = conf.api.activelog.includes(currentmod)
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod)
|
||||||
/**
|
/**
|
||||||
* @api {get} / - CheckHeaders
|
* @api {get} / - CheckHeaders
|
||||||
* @apiGroup Middlewares
|
* @apiGroup Middlewares
|
||||||
@@ -19,7 +19,7 @@ const log = conf.api.activelog.includes(currentmod)
|
|||||||
* @apiHeader {integer} xtrkversion a version number link to tracking system
|
* @apiHeader {integer} xtrkversion a version number link to tracking system
|
||||||
* @apiHeaderExample {json} Headeconst conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
* @apiHeaderExample {json} Headeconst conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod='checkHeaders';
|
const currentmod='checkHeaders';
|
||||||
const log = conf.api.activelog.includes(currentmod)r-Example for anonymous:
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod)r-Example for anonymous:
|
||||||
* {
|
* {
|
||||||
* "xtrkversion":1,
|
* "xtrkversion":1,
|
||||||
* "xtribe":"smatchit",
|
* "xtribe":"smatchit",
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ C - a json multi answer **{status,multimsg:\[{ref,msg,data}\]}**
|
|||||||
|
|
||||||
Each {ref,msg,data\] work the same way than B
|
Each {ref,msg,data\] work the same way than B
|
||||||
|
|
||||||
To show feedback context message in a language lg => get /api/adminapi/objects/tplstrings/{{model}}\_{{lg}}.json
|
To show feedback context message in a language lg => apxtri/tplstrings/{{model}}\_{{lg}}.json store in wwws.localdb
|
||||||
This contain a json {msg:"mustache template string to render with data"}
|
This contain a json {msg:"mustache template string to render with data"}
|
||||||
|
|
||||||
## Add tribe's api:
|
## Add tribe's api:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const openpgp = require("openpgp");
|
|||||||
|
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod='isAuthenticated';
|
const currentmod='isAuthenticated';
|
||||||
const log = conf.api.activelog.includes(currentmod)
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod)
|
||||||
/**
|
/**
|
||||||
* @api {get} / - isAuthenticated
|
* @api {get} / - isAuthenticated
|
||||||
* @apiGroup Middlewares
|
* @apiGroup Middlewares
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const Odmdb = require(`./Odmdb.js`);
|
|||||||
const Checkjson = require(`./Checkjson`);
|
const Checkjson = require(`./Checkjson`);
|
||||||
const conf = require(`../../objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod = "Articles";
|
const currentmod = "Articles";
|
||||||
const log = conf.api.activelog.includes(currentmod);
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||||
|
|
||||||
|
|
||||||
const Articles={}
|
const Articles={}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const Checkjson = require(`./Checkjson.js`);
|
|||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod = "Notifications";
|
const currentmod = "Notifications";
|
||||||
const log = conf.api.activelog.includes(currentmod);
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||||
/**
|
/**
|
||||||
* To manage any communication between Pagan
|
* To manage any communication between Pagan
|
||||||
* mayor druid emailing/sms/paper from tribe register smtp, simcard, mail api to Person(s) / Pagan(s)
|
* mayor druid emailing/sms/paper from tribe register smtp, simcard, mail api to Person(s) / Pagan(s)
|
||||||
@@ -139,12 +139,13 @@ Notifications.sendsms = async (data, tribeId) => {
|
|||||||
data: { tribe: tribeId },
|
data: { tribe: tribeId },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let missingk = [][("To", "Text")].forEach((k) => {
|
let missingk = [];
|
||||||
|
["To", "Text"].forEach((k) => {
|
||||||
if (!data[k]) {
|
if (!data[k]) {
|
||||||
missingk.push(k);
|
missingk.push(k);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (missingk.lenght > 0) {
|
if (missingk.length > 0) {
|
||||||
return {
|
return {
|
||||||
status: 428,
|
status: 428,
|
||||||
ref: "Notifications",
|
ref: "Notifications",
|
||||||
@@ -407,12 +408,12 @@ Notifications.sendmail = async (data, tribe) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let missingk = [];
|
let missingk = [];
|
||||||
["from", "to", "subject", "html", "text"].forEach((k) => {
|
["from", "to", "subject", "html", "text"].forEach((k) => {
|
||||||
if (!data[k]) {
|
if (!data[k]) {
|
||||||
missingk.push(k);
|
missingk.push(k);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (missingk.lenght > 0) {
|
if (missingk.length > 0) {
|
||||||
return {
|
return {
|
||||||
status: 428,
|
status: 428,
|
||||||
ref: "Notifications",
|
ref: "Notifications",
|
||||||
@@ -446,14 +447,14 @@ Notifications.sendmail = async (data, tribe) => {
|
|||||||
} else {
|
} else {
|
||||||
missingfile.push(fo.pathfile);
|
missingfile.push(fo.pathfile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (missingfile.lenght > 0)
|
if (missingk.length > 0) {
|
||||||
return {
|
return {
|
||||||
status: 428,
|
status: 428,
|
||||||
ref: "Notifications",
|
ref: "Notifications",
|
||||||
msg: "missingfile",
|
msg: "missingdata",
|
||||||
data: { missingfile: missingfile },
|
data: { missingk: missingk },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//console.log("data:", data);
|
//console.log("data:", data);
|
||||||
let res;
|
let res;
|
||||||
@@ -487,24 +488,29 @@ Notifications.sendmail = async (data, tribe) => {
|
|||||||
} else {
|
} else {
|
||||||
error = err;
|
error = err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (
|
console.log("sendmail result:", res);
|
||||||
res &&
|
if (res && res.accepted) {
|
||||||
res.accepted &&
|
// Normalize emails for comparison
|
||||||
data.to.split(",").reduce((acc, m) => acc && res.accepted.includes(m), true)
|
const normalizedAccepted = res.accepted.map(email => email.trim().toLowerCase());
|
||||||
) {
|
const toEmails = data.to.split(",").map(email => email.trim().toLowerCase());
|
||||||
data.accepted = res.accepted;
|
console.log("normalizedAccepted:", normalizedAccepted, "toEmails:", toEmails);
|
||||||
data.rejected = res.rejected;
|
const allAccepted = toEmails.every(email => normalizedAccepted.includes(email));
|
||||||
return {
|
|
||||||
status: 200,
|
if (allAccepted && (!res.rejected || res.rejected.length === 0)) {
|
||||||
ref: "Notifications",
|
data.accepted = res.accepted;
|
||||||
msg: "successfullsentemail",
|
data.rejected = res.rejected;
|
||||||
data,
|
return {
|
||||||
};
|
status: 200,
|
||||||
} else if (res && res.accepted && res.rejected) {
|
ref: "Notifications",
|
||||||
data.accepted = res.accepted;
|
msg: "successfullsentemail",
|
||||||
data.rejected = res.rejected;
|
data,
|
||||||
return { status: 410, ref: "Notifications", msg: "errsendmail", data };
|
};
|
||||||
|
} else {
|
||||||
|
data.accepted = res.accepted;
|
||||||
|
data.rejected = res.rejected;
|
||||||
|
return { status: 410, ref: "Notifications", msg: "errsendmail", data };
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
data.errmailer = error;
|
data.errmailer = error;
|
||||||
return { status: 417, ref: "Notifications", msg: "errsendmail", data };
|
return { status: 417, ref: "Notifications", msg: "errsendmail", data };
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
|||||||
const Checkjson = require(`./Checkjson.js`);
|
const Checkjson = require(`./Checkjson.js`);
|
||||||
const { promiseHooks } = require("v8");
|
const { promiseHooks } = require("v8");
|
||||||
const currentmod = "Odmdb";
|
const currentmod = "Odmdb";
|
||||||
const log = conf.api.activelog.includes(currentmod);
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||||
/**
|
/**
|
||||||
* This manage Objects for indexing, searching, checking and act to CRUD
|
* This manage Objects for indexing, searching, checking and act to CRUD
|
||||||
* @objectPathName = objectpath/objectname
|
* @objectPathName = objectpath/objectname
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const Odmdb = require("./Odmdb.js");
|
|||||||
|
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod = "Pagans";
|
const currentmod = "Pagans";
|
||||||
const log = conf.api.activelog.includes(currentmod);
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||||
/**
|
/**
|
||||||
* Pagan Management numeric Identity and Person (Person = Pagan Id + tribe)
|
* Pagan Management numeric Identity and Person (Person = Pagan Id + tribe)
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const Odmdb = require("./Odmdb.js");
|
|||||||
|
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod = "Pagans";
|
const currentmod = "Pagans";
|
||||||
const log = conf.api.activelog.includes(currentmod);
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||||
/**
|
/**
|
||||||
* Pagan Management numeric Identity and Person (Person = Pagan Id + tribe)
|
* Pagan Management numeric Identity and Person (Person = Pagan Id + tribe)
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const readlineSync = require("readline-sync");
|
|||||||
const Odmdb = require("./Odmdb.js");
|
const Odmdb = require("./Odmdb.js");
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod = "Wwws";
|
const currentmod = "Wwws";
|
||||||
const log = conf.api.activelog.includes(currentmod);
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||||
const Wwws = {};
|
const Wwws = {};
|
||||||
|
|
||||||
Wwws.getwco = (wconame, ctx) => {
|
Wwws.getwco = (wconame, ctx) => {
|
||||||
|
|||||||
@@ -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 = conf.api.activelog.includes(currentmod);
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
|||||||
@@ -730,33 +730,4 @@ router.put(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* @api {get} https://wall-ants.ndda.fr/adminapi/objects/tplstring/:modelname_lg.json - translation notif Get public
|
|
||||||
* @apiGroup Odmdb
|
|
||||||
* @apiName getPublicModelmessagekey
|
|
||||||
* @apiDescription Get a public json object for the ref: modelname in language lg, to get a template description with key msg
|
|
||||||
* @apiParam {string} modelname Mandatory
|
|
||||||
* @apiSuccess {json} contain json file
|
|
||||||
* @apiSuccessExample {json} Fichier direct
|
|
||||||
* HTTP/1.1 200 Success-response:
|
|
||||||
* {
|
|
||||||
"alreadyexist": "Un object {{objectname}} avec la clé {{key}} existe déjà avec {{val}}",
|
|
||||||
"doesnotexist": "L'object {{objectname}} avec la clé {{key}} ,'existe pas avec {{val}}",
|
|
||||||
"getschema": "Schema {{{conf.name}}}",
|
|
||||||
"schemanotfound": "Schema introuvable dans {{{schemaPath}}}",
|
|
||||||
"pathnamedoesnotexist": "Le repertoire n'existe pas {{{indexpath}}}",
|
|
||||||
"objectfiledoesnotexist": "Le fichier n'existe pas {{{objectpath}}}",
|
|
||||||
"cudsuccessfull": "Mise à jour effectuée avec succés",
|
|
||||||
"missingprimarykey": "Il manque une clé primaire apxid pour stocker et identifier les objects",
|
|
||||||
"unconsistencyapxidx": "L'index {{name}} doit contenir en objkey au moins {{apxid}} car keyval n'est pas unique",
|
|
||||||
"profilnotallow": "Vous n'avez pas le profil de {{profils}}, cette action n'est pas authorisée",
|
|
||||||
"successreindex": "Objet reindexé à partir des items, vos index sont à jour",
|
|
||||||
"indexexist":"L'indexe existe"
|
|
||||||
* }
|
|
||||||
* @apiError {json} contain json file
|
|
||||||
* @apiErrorExample {string} nginx html not found message
|
|
||||||
* HTTP/1.1 404 Not Found
|
|
||||||
* <html>...</html>
|
|
||||||
**/
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const isAuthenticated = require("../middlewares/isAuthenticated.js");
|
|||||||
|
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod = "Pagans";
|
const currentmod = "Pagans";
|
||||||
const log = conf.api.activelog.includes(currentmod);
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const fs = require("fs-extra");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod = "Trackings";
|
const currentmod = "Trackings";
|
||||||
const log = conf.api.activelog.includes(currentmod);
|
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||||
const Odmdb = require("../models/Odmdb.js");
|
const Odmdb = require("../models/Odmdb.js");
|
||||||
// Middlewares
|
// Middlewares
|
||||||
const checkHeaders = require("../middlewares/checkHeaders");
|
const checkHeaders = require("../middlewares/checkHeaders");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"aliasexist":"This alias {{alias]} exist",
|
"aliasexist":"This alias {{alias}} exist",
|
||||||
"aliasdoesnotexist":"This alias {{alias}} does not exist ",
|
"aliasdoesnotexist":"This alias {{alias}} does not exist ",
|
||||||
"personexist":"This person {{alias}} exist for {{tribeid}}",
|
"personexist":"This person {{alias}} exist for {{tribeid}}",
|
||||||
"successfullcreate": "This identity {{alias}} creation was successfull. {{#withemail}} An email was sent to {{email}}, if you do not receive it, please download your keys before living this page.{{/withemail}}",
|
"successfullcreate": "This identity {{alias}} creation was successfull. {{#withemail}} An email was sent to {{email}}, if you do not receive it, please download your keys before living this page.{{/withemail}}",
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#
|
#
|
||||||
# Exemple:
|
# Exemple:
|
||||||
# For setup
|
# For setup
|
||||||
#. /media/phil/usbfarm/apxtowns/dev-ants/adminapi/backup.sh /media/phil/usbfarm/apxtowns/dev-ants adminapi objects setup. "nations options pagans towns tplstrings wwws"
|
#. /media/phil/usbfarm/apxtowns/dev-ants/adminapi/backup.sh /media/phil/usbfarm/apxtowns/dev-ants adminapi objects setup. "nations options pagans towns wwws"
|
||||||
#. /media/phil/usbfarm/apxtowns/dev-ants/adminapi/backup.sh /media/phil/usbfarm/apxtowns/dev-ants adminapi apxtri setup. "middlewares models routes apidoc_adminapi.json apxchat.js apxtri.js package.json"
|
#. /media/phil/usbfarm/apxtowns/dev-ants/adminapi/backup.sh /media/phil/usbfarm/apxtowns/dev-ants adminapi apxtri setup. "middlewares models routes apidoc_adminapi.json apxchat.js apxtri.js package.json"
|
||||||
# For backup
|
# For backup
|
||||||
#. /media/phil/usbfarm/apxtowns/dev-ants/adminapi/backup.sh /media/phil/usbfarm/apxtowns/dev-ants adminapi objects dayname "persons"
|
#. /media/phil/usbfarm/apxtowns/dev-ants/adminapi/backup.sh /media/phil/usbfarm/apxtowns/dev-ants adminapi objects dayname "persons"
|
||||||
|
|||||||
Reference in New Issue
Block a user