Aggiunto comune, + filtro regione e provincia
aggiunto Visibilità (da fare check)
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando %s %s.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "%s %s accettati da %s.",
|
||||
"SALDO_UPDATE": "[Saldo <strong>%s %s</strong>]",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "%s %s accettati da %s.",
|
||||
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s.",
|
||||
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s.",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"Service: %s": "Servizio: %s",
|
||||
"<strong>%s</strong> new Good: %s": "<strong>%s</strong> nuovo Bene: %s",
|
||||
"<strong>%s</strong> new Service: %s": "<strong>%s</strong> nuovo Servizio: %s",
|
||||
"OPEN PAGE": "APRI PAGINA",
|
||||
"OPEN PAGE": "<em>APRI la APP RISO oppure visita riso.app</em>",
|
||||
"<strong>%s</strong> asked you for Friendship": "<strong>%s</strong> ti ha chiesto l'Amicizia",
|
||||
"<strong>%s</strong> accepted your Friendship": "<strong>%s</strong> ha accettato l'Amicizia",
|
||||
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> ha rifiutato l'Amicizia",
|
||||
@@ -51,10 +51,11 @@
|
||||
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal Circuito %s",
|
||||
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal Circuito %s",
|
||||
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando %s %s.",
|
||||
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando %s %s a %s.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "%s %s accettati da %s.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "%s %s sono stati accettati da %s.",
|
||||
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong>.",
|
||||
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando <strong>%s %s</strong> a %s. \nIl destinatario deve acettare la transazione.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "<strong>%s %s</strong> accettati da %s.",
|
||||
"SALDO_UPDATE": "[Saldo <strong>%s %s</strong>]",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "<strong>%s %s</strong> sono stati accettati da %s.",
|
||||
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s.",
|
||||
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s.",
|
||||
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa per %s",
|
||||
|
||||
@@ -53,6 +53,9 @@ const AccountSchema = new Schema({
|
||||
saldo: {
|
||||
type: Number,
|
||||
},
|
||||
totTransato: {
|
||||
type: Number,
|
||||
},
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@@ -116,6 +119,10 @@ AccountSchema.methods.addtoSaldo = async function(amount) {
|
||||
|
||||
if (account) {
|
||||
account.saldo = account.saldo + amount;
|
||||
if (!account.totTransato) {
|
||||
account.totTransato = 0;
|
||||
}
|
||||
account.totTransato += Math.abs(amount);
|
||||
account.date_updated = new Date();
|
||||
return await account.save();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,13 @@ const CircuitSchema = new Schema({
|
||||
subname: {
|
||||
type: String,
|
||||
},
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
|
||||
},
|
||||
longdescr: {
|
||||
type: String,
|
||||
},
|
||||
@@ -220,6 +227,8 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
fido_scoperto_default: 1,
|
||||
qta_max_default: 1,
|
||||
symbol: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
color: 1,
|
||||
abbrev: 1,
|
||||
data_costituz: 1,
|
||||
@@ -227,6 +236,7 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
admins: 1,
|
||||
req_users: 1,
|
||||
refused_users: 1,
|
||||
'mycities': 1,
|
||||
};
|
||||
|
||||
};
|
||||
@@ -255,6 +265,8 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
qta_max_default: 1,
|
||||
symbol: 1,
|
||||
color: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
abbrev: 1,
|
||||
data_costituz: 1,
|
||||
photos: 1,
|
||||
@@ -264,6 +276,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
date_updated: 1,
|
||||
req_users: 1,
|
||||
refused_users: 1,
|
||||
'mycities': 1,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -396,7 +409,11 @@ CircuitSchema.statics.getUserCircuits = async function(idapp, username) {
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: {idapp, username},
|
||||
$match: {idapp, username,
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
@@ -510,6 +527,9 @@ CircuitSchema.statics.sendCoins = async function(onlycheck, idapp, usernameOrig,
|
||||
|
||||
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
|
||||
|
||||
extrarec.saldoOrig = accountorigTable.saldo;
|
||||
extrarec.saldoDest = accountdestTable.saldo;
|
||||
|
||||
} else {
|
||||
console.log('NON Inviate Monete da', usernameOrig, extrarec.dest, myqty, extrarec.causal);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,9 @@ MovementSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
MovementSchema.statics.addMov = async function(idapp, accountFromIdTable, accountToIdTable, amount, causal) {
|
||||
|
||||
try {
|
||||
// Only positive values
|
||||
amount = Math.abs(amount);
|
||||
|
||||
let mymov = Movement(
|
||||
{
|
||||
_id: new ObjectID().toString(),
|
||||
|
||||
@@ -171,6 +171,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
'mycities': 1,
|
||||
reported: 1,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -51,6 +51,10 @@ const sendNotifSchema = new Schema({
|
||||
datenotif: {
|
||||
type: Date,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
status: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
@@ -144,7 +148,7 @@ sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function(username, la
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
||||
sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
|
||||
const numchars = 80;
|
||||
let newdescr = '';
|
||||
@@ -321,7 +325,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
||||
}
|
||||
tag = 'removeadmincircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', recnotif.paramsObj.username_action, recnotif.paramsObj.extrarec.qty.toString(),
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', tools.getAhref(recnotif.paramsObj.username_action, await tools.getLinkUserTelegram(recnotif.idapp, recnotif.paramsObj.username_action)), recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol);
|
||||
tag = 'sendcoin';
|
||||
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
|
||||
@@ -332,12 +336,15 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
||||
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action);
|
||||
recnotif.paramsObj.username_action) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest,
|
||||
recnotif.paramsObj.extrarec.symbol
|
||||
);
|
||||
tag = 'sendcoin';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_TO_ME', recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.extrarec.dest);
|
||||
recnotif.paramsObj.extrarec.dest) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoOrig,
|
||||
recnotif.paramsObj.extrarec.symbol);
|
||||
tag = 'sendcoin';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
@@ -346,7 +353,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED_TO_ME', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.extrarec.dest);
|
||||
tag = 'sendcoin';
|
||||
tag = 'sendcoin';ac
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,7 +458,7 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
try {
|
||||
if (!myrecnotif.openUrl) {
|
||||
// If not exist, then I set openUrl and description
|
||||
myrecnotif = this.getDescrAndLinkByRecNotif(myrecnotif);
|
||||
myrecnotif = await this.getDescrAndLinkByRecNotif(myrecnotif);
|
||||
}
|
||||
|
||||
let newstatus = 0;
|
||||
@@ -523,8 +530,9 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
if (newstatus) {
|
||||
const fields_to_update = {
|
||||
status: newstatus,
|
||||
read: true,
|
||||
read: false,
|
||||
descr: myrecnotif.descr,
|
||||
datenotif: new Date(),
|
||||
};
|
||||
|
||||
let query = {
|
||||
@@ -753,7 +761,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
myrecnotifpass.myrectableorig = myrectableorig;
|
||||
}
|
||||
|
||||
myrecnotifpass = this.getDescrAndLinkByRecNotif(myrecnotifpass);
|
||||
myrecnotifpass = await this.getDescrAndLinkByRecNotif(myrecnotifpass);
|
||||
delete myrecnotifpass._doc['_id'];
|
||||
|
||||
for (const user of userlist) {
|
||||
|
||||
@@ -2642,6 +2642,16 @@ UserSchema.statics.SetTelegramIdSuccess = async function(idapp, id, teleg_id) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsernameTelegram = async function(idapp, username) {
|
||||
const User = this;
|
||||
return await User.findOne({idapp, username}, {'profile.username_telegram': 1}).lean().then((ris) => {
|
||||
if (ris)
|
||||
return ris.profile.username_telegram
|
||||
else
|
||||
return '';
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.setUsernameTelegram = async function(
|
||||
idapp, id, username_telegram, firstname_telegram, lastname_telegram) {
|
||||
const User = this;
|
||||
|
||||
@@ -161,6 +161,12 @@ module.exports = {
|
||||
"label" : "Monete Alternative",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b254ac"),
|
||||
"idapp" : "13",
|
||||
"label" : "RIS",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b254fb"),
|
||||
"idapp" : "13",
|
||||
|
||||
@@ -370,7 +370,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
mytablerec.date_updated = new Date();
|
||||
}
|
||||
|
||||
console.log('mydata',mydata);
|
||||
// console.log('mydata',mydata);
|
||||
|
||||
return await mytablerec.save().
|
||||
then(async (rec) => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
@@ -62,6 +61,28 @@ router.get('/setall/:username/:qualinotif/:idapp', authenticate, async (req, res
|
||||
|
||||
});
|
||||
|
||||
router.get('/set/:_id/:idapp', authenticate, async (req, res) => {
|
||||
|
||||
const _id = req.params._id;
|
||||
const username_call = req.user.username;
|
||||
|
||||
try {
|
||||
let query = {_id, dest: username_call, read: false};
|
||||
|
||||
const rec = await SendNotif.findOne(query);
|
||||
if (rec) {
|
||||
rec.read = true;
|
||||
await rec.save();
|
||||
return res.send(true);
|
||||
}
|
||||
res.send(false);
|
||||
|
||||
} catch (e) {
|
||||
res.status(400).send(e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
router.get('/del/:username/:id/:idapp', authenticate, async (req, res) => {
|
||||
|
||||
const idapp = req.params.idapp;
|
||||
@@ -123,14 +144,14 @@ router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => {
|
||||
return res.status(404).send({code: server_constants.RIS_CODE_NOT_MY_USERNAME});
|
||||
}
|
||||
|
||||
return SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp).then( async (arrnotif) => {
|
||||
return SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp).then(async (arrnotif) => {
|
||||
// const wait = new Promise((resolve, reject) => {
|
||||
// setTimeout(() => {
|
||||
|
||||
//++Todo: Ottimizzare ! Non occorre inviare tutti questi dati !!! Solo per il Circuito ?!
|
||||
const userprofile = await User.getExtraInfoByUsername(idapp, req.user.username);
|
||||
|
||||
return res.send({arrnotif, userprofile } );
|
||||
return res.send({arrnotif, userprofile});
|
||||
|
||||
}).catch((e) => {
|
||||
console.log(e.message);
|
||||
|
||||
@@ -578,6 +578,7 @@ module.exports = {
|
||||
'title',
|
||||
'openUrl',
|
||||
'datenotif',
|
||||
'date_updated',
|
||||
'read',
|
||||
'deleted',
|
||||
'idapp',
|
||||
@@ -750,6 +751,8 @@ module.exports = {
|
||||
|
||||
content = this.convertHTMLtoText(content);
|
||||
|
||||
content = this.ConvertHTMLToPlainText(content);
|
||||
|
||||
let payload = {
|
||||
actions,
|
||||
title: title,
|
||||
@@ -1313,6 +1316,10 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
ConvertHTMLToPlainText(strHTML) {
|
||||
return strHTML.replace(/<[^>]+>/g, '');
|
||||
},
|
||||
|
||||
convertHTMLtoText(myhtml) {
|
||||
let msg = myhtml;
|
||||
msg = msg.replace('"', '"');
|
||||
@@ -1383,6 +1390,23 @@ module.exports = {
|
||||
return this.getHostByIdApp(idapp) + '/my/' + username;
|
||||
},
|
||||
|
||||
getLinkUserTelegram: async function(idapp, username, myuser) {
|
||||
var {User} = require('../models/user');
|
||||
|
||||
let u_tg = '';
|
||||
if (myuser)
|
||||
u_tg = myuser.profile && myuser.profile.hasOwnProperty('username_telegram') ? myuser.profile.username_telegram : usernametelegram;
|
||||
|
||||
if (!u_tg) {
|
||||
u_tg = await User.getUsernameTelegram(idapp, username);
|
||||
}
|
||||
|
||||
if (u_tg)
|
||||
return `https://t.me/${u_tg}`;
|
||||
else
|
||||
return '';
|
||||
},
|
||||
|
||||
getLinkEditUserProfile: function(idapp) {
|
||||
return this.getHostByIdApp(idapp) + '/editprofile';
|
||||
},
|
||||
@@ -3296,11 +3320,17 @@ module.exports = {
|
||||
|
||||
let myhost = this.getHostByIdApp(params.idapp);
|
||||
|
||||
if (params.openUrl)
|
||||
/*if (params.openUrl)
|
||||
content = content + '\n' + '<a href="' + myhost + params.openUrl + '">' + i18n.__('OPEN PAGE') + '</a>';
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
return content;
|
||||
},
|
||||
|
||||
getAhref(username, link) {
|
||||
return `<a href='${link}'>${username}</a>`;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user