1
0
forked from apxtri/apxtri

clean notification with last folder change

This commit is contained in:
philc 2024-03-19 09:10:07 +01:00
parent dbd8cf72a0
commit b1a6948398
8 changed files with 47 additions and 31 deletions

View File

@ -65,7 +65,7 @@ Pre-request: linux maxhine on a vps or physical machine ( we choose ubuntu serve
To start you need to 
* setup your network and for production a Domain Name server and a SSL certificat to your IP town
* setup your machine by installing smap, nginx, nvm, npm, node
* setup your machine by installing snap, nginx, nvm, npm, node
As a mayor, you have to understand what you are doing, your numeric reputation is in the game. Always check sources before downloading any things. For dev use town name: **dev** and nation name :**ants** 
@ -92,11 +92,11 @@ $ ip -4 address # to get your (local) LAN IP of your server
Connect in your browser to your box (use your LAN IP and change last number by 1) Set as a dmz your local LAN IP and route (NAT) your internet trafic port 80 and 443 to this local IP.
This allow public access from internet to your DMZ local server.  Think to use reverse proxy to be more anonymous. Contacts the community to help keeping your anonymous.
This allow public access from internet to your DMZ local server.  Think to use reverse proxy to be more anonymous. Contacts the community to help keeping you anonymous if you want.
### Machine: 
use a sudoer user and execute command line $, for security reason, do not use apxuser replace it by something not common (as admin, mayor,… use your nickname or pseudo)
use a sudoer user and execute command line $, for security reason, do not use apxuser replace it by something not common ( not as admin, mayor,… use your nickname or pseudo)
```plaintext
$ sudo apt update
@ -126,7 +126,8 @@ $ mkdir ~/apxtowns | mkdir ~/apxtowns/town-nation
#################################
# For dev #######################
#################################
# you only need to clone the apXtri project in ~/apxtowns/town-nation/tribes/adminapi/, this allow you push features to the maintainers of the project:
# you only need to clone the apXtri project in ~/apxtowns/town-nation/tribes/adminapi/
# this allow you to dev foar a tribe api as well as to push features to the maintainers of the apXtri project:
$ curl -L https://wall-ants.fr/cdn/setupdev.tar | tar -xvzf - -C ~/apxtowns/town-nation/
$ cd ~/apxtowns/town-nation/tribes/adminapi/
$ git clone https://gitea.ndda.fr/apxtrib/apxtri.git
@ -174,7 +175,7 @@ apxtri core : https://dns/cdn/apidoclist all endpoint and how authentification a
* how notification can cypher message between 2 pagans to communicate
* how a dev can create and host a tribe and a full project with api backend (documented with apidoc) and a webapp (in react, vue, angular, or a simple web page)
### Main end-point:
### Main end-points:
* Odmdb : data model management and accessright
* Pagans : numeric Identity with person to join a tribe
@ -193,7 +194,7 @@ A webapp allow you to manage a town as mayor or as a druid access it and authent
If you want to join our task force to make this libertarian project live feel free to contact us on discord in apXtri server 
We are looking for dev (node.js, express.js, js, web developper), for translator, for trainner, for mayor and druid from any countries  that want developp a business with their machine/bandwisdth annd a client community.
We are looking for dev (node.js, express.js, js, web developper), for translator, for trainner, for mayor and druid from any countries  that want developp a business with their machine/bandwidth and local communities.
Dev
@ -205,5 +206,9 @@ Dev
Community managers and user
* animate the apXtri discord and social network to dev the user community
* translate content app for italian, german, spanish, 
* creator or producer of any valueable stuff to sale/exchange any things into your community
* translate content app for italian, german, spanish,
* creator or producer of any valueable stuff to sale/exchange any things into your community
Trainer / Teacher
* Teach blcockchain and almternative currency system (Monero, bitcoin, xtr…) and

View File

@ -2,7 +2,7 @@ const conf = require(`../../../../conf/townconf.json`);
const currentmod='checkHeaders';
const log = conf.api.activelog.includes(currentmod)
/**
* @api {get} http://header/CheckHeaders - CheckHeaders
* @api {get} / - CheckHeaders
* @apiGroup Middlewares
* @apiName CheckHeaders
* @apiDescription a list of headers are mandatory to access apxtri see in your space town /conf.json.exposedHeaders

View File

@ -32,12 +32,18 @@ All others object are managed by spécifics tribe. 
/api
/objects/objectname/idx/ # list of index to search objectname items
/itms/ # 1 json per items name apxid.json where apxid is a unique key
/wwws/idx/
/itm/
appname.json # website appname conf
cdn.json
/appname/ # website files
/cdn/ # cached files to optimize nginx static file delivery
/schema/conf.json # list of schema and version
/objectname.json # schema title and escription are in english
/lg/objectname_lg.json # title and description in lg
/www/appname # web space
/cdn # common file with cache system
/tribename/ # same than adminapi but wit /api instead of apxtri
/tribename/ # same than adminapi for a specific tribe but wit /api instead of /apxtri,
# we only have 1 node process that manage 1 town that manage many tribes api
```
API Endpoint url: **/api/{tribename}/{routename}/xxx**
@ -88,14 +94,14 @@ See Pagans models that contain authentification process
A - data file from a classical get  [https://wall-ants.ndda.fr/Checkjson.js](https://smatchit.io/Checkjson.js)
B -  a json single answer {status, ref,msg,data}:
B -  a json single answer **{status, ref,msg,data}:**
* status: http code return
* ref: model/route name reference where message come from
* msg: a message template key store into models/lg/name\_lg.json (where lg is 2 letters language)
* data: an object data use to render the value of the message key.
C - a json multi answer {status,multimsg:\[{ref,msg,data}\]}
C - a json multi answer **{status,multimsg:\[{ref,msg,data}\]}**
         Each {ref,msg,data\] work the same way than B
@ -104,9 +110,9 @@ This contain a json {msg:"mustache template string to render with data"}  
## Accessrights:
An alias is just an identity, to access a tribe, a person must exist with an authenticated alias into /tribes/{tribename}/persons/itm/{alias}.json/tribes/tribename/api/routes/
An alias is just an identity, to access a tribe, a person must exist with an authenticated alias into /tribes/{tribename}/objects/persons/itm/{alias}.json
A person has a property profils with a list of profilename, common profiles are : anonymous (no identity) / pagan (an identity)  / person (an identity with access right into a tribe) / druid (the administrator of a tribe) / major (administrator of a town/server)
A person has a property profils with a list of profilename, common profiles are : anonymous (no identity) / pagan (an identity)  / person (an identity with access right into a tribe) / druid (the administrator of a tribe) / mayor (administrator of a town/server)
Each object has an apxaccessrights that is a list of profil and CRUD access per object key .
@ -124,8 +130,13 @@ Accessible with https://dns/api/tribename/routes
```plaintext
// Example of a route
const tribe="smatchit";
const conftrib = require(`../../../itm/${tribe}.json`);
const conf = require(`../../../../conf/townconf.json`);
const express = require(`../../../adminapi/apxtri/node_modules/express`);
const fs = require(`../../../adminapi/apxtri/node_modules/fs-extra`);
const Nofications = require(`../../../adminapi/apxtri/models/Notifications.js`);
const Appscreens = require(`../models/Appscreens`);
const router=express.Router();
module.exports=router;
```

View File

@ -10,7 +10,7 @@ const conf = require(`../../../../conf/townconf.json`);
const currentmod='isAuthenticated';
const log = conf.api.activelog.includes(currentmod)
/**
* @api {get} http://header/istauthenticated - isAuthenticated
* @api {get} / - isAuthenticated
* @apiGroup Middlewares
* @apiName isAuthenticated
* @apiDescription - valid if exist xalias_xdays_xhash.substr(20,200) in town/tmp/tokens/

View File

@ -18,7 +18,7 @@ const log = conf.api.activelog.includes(currentmod);
const Notifications = {};
Notifications.get = (alias, tribeId) => {
const notiffile = `../../../${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 = `../../../${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}}
@ -116,11 +116,11 @@ Notifications.sendsms = async (data, tribeId) => {
let confsms = conf.sms;
if (
fs.existsSync(
`../../../itm/${req.session.header.xtribe}.json`
`../../itm/${req.session.header.xtribe}.json`
)
) {
const conftrib = fs.readJSONSync(
`../../../itm/${req.session.header.xtribe}.json`
`../../itm/${req.session.header.xtribe}.json`
);
if (conftrib.sms) confsms = conftrib.sms;
}
@ -225,7 +225,7 @@ Notifications.sendmail = async (data, tribe) => {
};
}
let confsmtp = conf.smtp;
const conftribfile = `../../../itm/${tribe}.json`;
const conftribfile = `../../itm/${tribe}.json`;
if (fs.existsSync(conftribfile)) {
const conftrib = fs.readJSONSync(conftribfile);
confsmtp = conftrib.smtp;

View File

@ -15,7 +15,7 @@
"restartapx": "pm2 restart apxtri.js --log-date-format 'DD-MM HH:mm:ss.SSS'",
"dev": "NODE_MODE=dev node apxtri.js",
"unittest": "node unittest.js",
"apidoc": "apidoc -c ../../../conf/apidoc/apidoc_$tribe.json -o ../../$tribe/www/cdn/apidoc/",
"apidoc": "apidoc -c ../../../conf/apidoc/apidoc_$tribe.json -o ../../$tribe/objects/wwws/cdn/apidoc/",
"publishtestwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/testwall-ants/tribes/$space/..",
"publishwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/wall-ants/tribes/$space/..",
"publishhouse": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@house-ants://home/phil/apxtowns/house-ants/tribes/$space/.."

View File

@ -10,7 +10,7 @@ const isAuthenticated = require("../middlewares/isAuthenticated.js");
const router = express.Router();
/**
* @api {get} adminapi/odmdb/schemas - objects Get
* @api {get} /adminapi/odmdb/schemas - objects Get
* @apiGroup Odmdb
* @apiName getIndex
* @apiDescription Get objects available result is store in data.apx.conf for schema conf of adminapi schema (pagans,towns,... ) and data.apx.objectnames as array of schema name. Schema related to tribe are store in data.tribe.conf and data.tribe.objectnames where tribe come from header.xtribe
@ -47,7 +47,7 @@ router.get("/schemas", checkHeaders, isAuthenticated, (req, res) => {
res.status(200).json({ status: 200, ref: "Odmdb", msg: "objectslist", data });
});
/**
* @api {get} adminapi/odmdb/schema/:source/:objectname - Schema Get in the language header
* @api {get} /adminapi/odmdb/schema/:source/:objectname - Schema Get in the language header
* @apiGroup Odmdb
* @apiName getIndex
* @apiDescription Get schema in the requested language if login have accessright
@ -74,7 +74,7 @@ router.get("/schema/:source/:objectname", checkHeaders, isAuthenticated, (req, r
});
/**
* @api {get} adminapi/odmdb/idx/:tribe/:objectname/:indexname - index Get
* @api {get} /adminapi/odmdb/idx/:tribe/:objectname/:indexname - index Get
* @apiGroup Odmdb
* @apiName getIndex
* @apiDescription Get index file for an object
@ -129,7 +129,7 @@ router.get(
);
/**
* @api {get} adminapi/odmdb/rebuildidx/:objectname - index refresh all
* @api {get} /adminapi/odmdb/rebuildidx/:objectname - index refresh all
* @apiGroup Odmdb
* @apiName refreshAllIndex
* @apiDescription Rebuild all index for an object, this can be usefull in case crash or any data conflict.
@ -199,7 +199,7 @@ router.get(
);
/**
* @api {post} adminapi/odmdb/itm/:objectname - item Create
* @api {post} /adminapi/odmdb/itm/:objectname - item Create
* @apiGroup Odmdb
* @apiName postItm
* @apiPermission none
@ -258,7 +258,7 @@ router.get(
);
/**
* @api {get} adminapi/odmdb/itm/:objectname/:primaryindex - item Get
* @api {get} /adminapi/odmdb/itm/:objectname/:primaryindex - item Get
* @apiGroup Odmdb
* @apiName getItemFromId
* @apiDescription Get itm for a primaryid of an object

View File

@ -92,7 +92,8 @@ router.get("/isauth", checkHeaders, isAuthenticated, (req, res) => {
},
});
});
// @a pi Body {object} schema:pagans <a href='/nationchains/schema/pagans.json' target='_blank'>/nationchains/schema/pagans.json</a>
/**
* @api {post} adminapi/pagans - pagan Post
* @apiName addpagan
@ -111,7 +112,6 @@ router.get("/isauth", checkHeaders, isAuthenticated, (req, res) => {
* @apiBody {string} [privatekey]
* @apiBody {string} [passphrase] if not specidied => passphrase=""
* @apiBody {string} [trustedtribe] the tribename if not specified then the process will only create a pagan identity, else an item person is create for trustedtribe (that must exist with profil 'person'). To create a person with an existing pagan identity use put /api/person/:alias after authenticated you (headers). In case a person is created then we use all valid other apiBody respecting the persons schema (see put persons)
* @apiBody {object} schema:pagans <a href='/nationchains/schema/pagans.json' target='_blank'>/nationchains/schema/pagans.json</a>
*
* @apiError {json} objectNotfound the file does not exist
* @apiErrorExample {json}