modif notification email
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -18,6 +18,4 @@
|
||||
!objects/
|
||||
!objects/options/
|
||||
!objects/options/**
|
||||
!objects/tplstrings/
|
||||
!objects/tplstrings/**
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
||||
if (!doms.includes(dm)) doms.push(dm);
|
||||
//reindex database attention check dev-ants/.. a bug was fixed
|
||||
glob.sync(`../${t}/objects/*`).forEach((o) => {
|
||||
//console.log("reindex: ", o);
|
||||
console.log("reindex: ", o);
|
||||
Odmdb.runidx(o);
|
||||
});
|
||||
});
|
||||
@@ -242,7 +242,7 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
||||
context.routes.push(rt);
|
||||
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")}`;
|
||||
return {
|
||||
model: modname,
|
||||
@@ -251,6 +251,7 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
||||
.map((l) => path.basename(l, ".json").split("_")[1]),
|
||||
};
|
||||
});
|
||||
*/
|
||||
//console.log(context.routes);
|
||||
//console.log(context.models);
|
||||
//const conft = `../itm/${t}.json`;
|
||||
@@ -274,8 +275,8 @@ apxtri.runexpress = async (tribesdns, conf) => {
|
||||
app.disable("x-powered-by"); // for security
|
||||
app.locals.tribeids = tribeIds;
|
||||
const currentmod = "apxtri";
|
||||
const log = conf.api.activelog
|
||||
? conf.api.activelog.includes(currentmod)
|
||||
const log = process.env.ACTIVELOG.split(',')
|
||||
? process.env.ACTIVELOG.split(',').includes(currentmod)
|
||||
: false;
|
||||
console.log(
|
||||
currentmod,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const path=require('path')
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod='checkHeaders';
|
||||
const log = conf.api.activelog.includes(currentmod)
|
||||
const log = process.env.ACTIVELOG.split(',').includes(currentmod)
|
||||
/**
|
||||
* @api {get} / - CheckHeaders
|
||||
* @apiGroup Middlewares
|
||||
@@ -19,7 +19,7 @@ const log = conf.api.activelog.includes(currentmod)
|
||||
* @apiHeader {integer} xtrkversion a version number link to tracking system
|
||||
* @apiHeaderExample {json} Headeconst conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
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,
|
||||
* "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
|
||||
|
||||
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"}
|
||||
|
||||
## Add tribe's api:
|
||||
|
||||
@@ -8,7 +8,7 @@ const openpgp = require("openpgp");
|
||||
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod='isAuthenticated';
|
||||
const log = conf.api.activelog.includes(currentmod)
|
||||
const log = process.env.ACTIVELOG.split(',').includes(currentmod)
|
||||
/**
|
||||
* @api {get} / - isAuthenticated
|
||||
* @apiGroup Middlewares
|
||||
|
||||
@@ -7,7 +7,7 @@ const Odmdb = require(`./Odmdb.js`);
|
||||
const Checkjson = require(`./Checkjson`);
|
||||
const conf = require(`../../objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "Articles";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||
|
||||
|
||||
const Articles={}
|
||||
|
||||
@@ -9,7 +9,7 @@ const Checkjson = require(`./Checkjson.js`);
|
||||
const nodemailer = require("nodemailer");
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "Notifications";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||
/**
|
||||
* To manage any communication between Pagan
|
||||
* 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 },
|
||||
};
|
||||
}
|
||||
let missingk = [][("To", "Text")].forEach((k) => {
|
||||
let missingk = [];
|
||||
["To", "Text"].forEach((k) => {
|
||||
if (!data[k]) {
|
||||
missingk.push(k);
|
||||
}
|
||||
});
|
||||
if (missingk.lenght > 0) {
|
||||
if (missingk.length > 0) {
|
||||
return {
|
||||
status: 428,
|
||||
ref: "Notifications",
|
||||
@@ -407,12 +408,12 @@ Notifications.sendmail = async (data, tribe) => {
|
||||
}
|
||||
|
||||
let missingk = [];
|
||||
["from", "to", "subject", "html", "text"].forEach((k) => {
|
||||
["from", "to", "subject", "html", "text"].forEach((k) => {
|
||||
if (!data[k]) {
|
||||
missingk.push(k);
|
||||
}
|
||||
});
|
||||
if (missingk.lenght > 0) {
|
||||
if (missingk.length > 0) {
|
||||
return {
|
||||
status: 428,
|
||||
ref: "Notifications",
|
||||
@@ -446,14 +447,14 @@ Notifications.sendmail = async (data, tribe) => {
|
||||
} else {
|
||||
missingfile.push(fo.pathfile);
|
||||
}
|
||||
});
|
||||
if (missingfile.lenght > 0)
|
||||
return {
|
||||
status: 428,
|
||||
ref: "Notifications",
|
||||
msg: "missingfile",
|
||||
data: { missingfile: missingfile },
|
||||
};
|
||||
});
|
||||
if (missingk.length > 0) {
|
||||
return {
|
||||
status: 428,
|
||||
ref: "Notifications",
|
||||
msg: "missingdata",
|
||||
data: { missingk: missingk },
|
||||
};
|
||||
}
|
||||
//console.log("data:", data);
|
||||
let res;
|
||||
@@ -487,24 +488,29 @@ Notifications.sendmail = async (data, tribe) => {
|
||||
} else {
|
||||
error = err;
|
||||
}
|
||||
}
|
||||
if (
|
||||
res &&
|
||||
res.accepted &&
|
||||
data.to.split(",").reduce((acc, m) => acc && res.accepted.includes(m), true)
|
||||
) {
|
||||
data.accepted = res.accepted;
|
||||
data.rejected = res.rejected;
|
||||
return {
|
||||
status: 200,
|
||||
ref: "Notifications",
|
||||
msg: "successfullsentemail",
|
||||
data,
|
||||
};
|
||||
} else if (res && res.accepted && res.rejected) {
|
||||
data.accepted = res.accepted;
|
||||
data.rejected = res.rejected;
|
||||
return { status: 410, ref: "Notifications", msg: "errsendmail", data };
|
||||
}
|
||||
console.log("sendmail result:", res);
|
||||
if (res && res.accepted) {
|
||||
// Normalize emails for comparison
|
||||
const normalizedAccepted = res.accepted.map(email => email.trim().toLowerCase());
|
||||
const toEmails = data.to.split(",").map(email => email.trim().toLowerCase());
|
||||
console.log("normalizedAccepted:", normalizedAccepted, "toEmails:", toEmails);
|
||||
const allAccepted = toEmails.every(email => normalizedAccepted.includes(email));
|
||||
|
||||
if (allAccepted && (!res.rejected || res.rejected.length === 0)) {
|
||||
data.accepted = res.accepted;
|
||||
data.rejected = res.rejected;
|
||||
return {
|
||||
status: 200,
|
||||
ref: "Notifications",
|
||||
msg: "successfullsentemail",
|
||||
data,
|
||||
};
|
||||
} else {
|
||||
data.accepted = res.accepted;
|
||||
data.rejected = res.rejected;
|
||||
return { status: 410, ref: "Notifications", msg: "errsendmail", data };
|
||||
}
|
||||
} else {
|
||||
data.errmailer = error;
|
||||
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 { promiseHooks } = require("v8");
|
||||
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
|
||||
* @objectPathName = objectpath/objectname
|
||||
|
||||
@@ -10,7 +10,7 @@ const Odmdb = require("./Odmdb.js");
|
||||
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
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)
|
||||
*
|
||||
|
||||
@@ -10,7 +10,7 @@ const Odmdb = require("./Odmdb.js");
|
||||
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
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)
|
||||
*
|
||||
|
||||
@@ -12,7 +12,7 @@ const readlineSync = require("readline-sync");
|
||||
const Odmdb = require("./Odmdb.js");
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "Wwws";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||
const Wwws = {};
|
||||
|
||||
Wwws.getwco = (wconame, ctx) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ const Articles = require(`../models/Articles`);
|
||||
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "Articles";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||
|
||||
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;
|
||||
|
||||
@@ -11,7 +11,7 @@ const isAuthenticated = require("../middlewares/isAuthenticated.js");
|
||||
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "Pagans";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||
const currentmod = "Trackings";
|
||||
const log = conf.api.activelog.includes(currentmod);
|
||||
const log = process.env.ACTIVELOG.split(',').includes(currentmod);
|
||||
const Odmdb = require("../models/Odmdb.js");
|
||||
// Middlewares
|
||||
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 ",
|
||||
"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}}",
|
||||
@@ -9,7 +9,7 @@
|
||||
#
|
||||
# Exemple:
|
||||
# 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"
|
||||
# For backup
|
||||
#. /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