Visu Sent Monete
This commit is contained in:
@@ -24,5 +24,36 @@
|
||||
"GROUP_REQUEST_TO_ENTER": "%s asked to join the group %s",
|
||||
"GROUP_REQUEST": "Richiesta di entrare nel Gruppo %s da parte di %s",
|
||||
"RICHIESTA_BLOCCO_GRUPPO": "Richiesta di bloccare il Gruppo %s da parte di %s",
|
||||
"GRUPPO_ELIMINATO": "Il gruppo %s è stato eliminato da parte di %s"
|
||||
"GRUPPO_ELIMINATO": "Il gruppo %s è stato eliminato da parte di %s",
|
||||
"FRIEND_REPORTED_TO_ME": "Sei stato segnalato da %s per comportamenti non idonei. Contatta %s per chiarimenti",
|
||||
"FRIEND_REPORTED": "E' stato segnalato %s da %s per comportamenti non idonei.",
|
||||
"FRIEND_REPORTED_YOU": "Hai segnalato %s per comportamenti non idonei.",
|
||||
"FRIEND_UNBLOCKED_TO_ME": "Sei stato riattivato da %s",
|
||||
"FRIEND_UNBLOCKED": "E' stato riattivato %s da %s.",
|
||||
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Accetta Ingresso nel Circuito %s:",
|
||||
"CIRCUIT_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel circuito %s",
|
||||
"CIRCUIT_CREATED": "✅ %s ha creato un nuovo Circuito chiamato %s",
|
||||
"CIRCUIT_REQUEST": "Richiesta di entrare nel Circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN_YOU": "Sei stato aggiunto come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN_YOU": "Ti è stato rimosso l'incarico di Amministratore del circuito %s da parte di %s",
|
||||
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il Circuito %s da parte di %s",
|
||||
"CIRCUIT_ELIMINATO": "Il circuito %s è stato eliminato da parte di %s",
|
||||
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Circuito %s. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
|
||||
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_REFUSED_TO_ME": "All'utente %s gli è stato rifiutato l'accesso a far parte del Circuito %s (da parte di %s).",
|
||||
"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.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "%s %s accettati da %s.",
|
||||
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa",
|
||||
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario può accumulare",
|
||||
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
|
||||
"STATUS_SENT": "Inviato",
|
||||
"STATUS_REFUSED": "Rifiutato"
|
||||
}
|
||||
|
||||
@@ -1,58 +1,61 @@
|
||||
{
|
||||
"Hello": "Ciao",
|
||||
"Hello %s": "Ciao %s",
|
||||
"Good: %s": "Bene: %s",
|
||||
"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",
|
||||
"<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",
|
||||
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
||||
"✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !",
|
||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Gruppo %s (da parte di %s)",
|
||||
"GROUPS_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Gruppo %s. Se pensi sia un'errore, contatta l'amministratore del Gruppo.",
|
||||
"GROUPS_REMOVED": "❌ l'utente %s è stato rimosso del Gruppo %s (da parte di %s)",
|
||||
"GROUPS_EXIT_USER": "❌ l'utente %s è uscito dal Gruppo %s",
|
||||
"GROUPS_EXIT_USER_TO_ME": "❌ Sei uscito dal Gruppo %s",
|
||||
"GROUPS_REMOVED_TO_ME": "❌ Sei stato rimosso dal Gruppo %s (da parte di %s)",
|
||||
"ACCETTATO_NOTIFICA_ADMINS": "✅ l'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)",
|
||||
"GROUP_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel gruppo %s",
|
||||
"GROUP_CREATED": "✅ %s ha creato un nuovo Gruppo chiamato %s",
|
||||
"GROUP_REQUEST": "Richiesta di entrare nel Gruppo %s da parte di %s",
|
||||
"GROUPS_ADDED_ADMIN_GROUP": "E' stato aggiunto %s come Amministratore del gruppo %s da parte di %s",
|
||||
"GROUPS_ADDED_ADMIN_GROUP_YOU": "Sei stato aggiunto come Amministratore del gruppo %s da parte di %s",
|
||||
"GROUPS_REMOVED_ADMIN_GROUP": "E' stato rimosso l'incarico di Amministratore a %s del gruppo %s da parte di %s",
|
||||
"GROUPS_REMOVED_ADMIN_GROUP_YOU": "Ti è stato rimosso l'incarico di Amministratore del gruppo %s da parte di %s",
|
||||
"RICHIESTA_BLOCCO_GRUPPO": "Richiesta di bloccare il Gruppo %s da parte di %s",
|
||||
"GRUPPO_ELIMINATO": "Il gruppo %s è stato eliminato da parte di %s",
|
||||
"FRIEND_REPORTED_TO_ME": "Sei stato segnalato da %s per comportamenti non idonei. Contatta %s per chiarimenti",
|
||||
"FRIEND_REPORTED": "E' stato segnalato %s da %s per comportamenti non idonei.",
|
||||
"FRIEND_REPORTED_YOU": "Hai segnalato %s per comportamenti non idonei.",
|
||||
"FRIEND_UNBLOCKED_TO_ME": "Sei stato riattivato da %s",
|
||||
"FRIEND_UNBLOCKED": "E' stato riattivato %s da %s.",
|
||||
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Accetta Ingresso nel Circuito %s:",
|
||||
"CIRCUIT_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel circuito %s",
|
||||
"CIRCUIT_CREATED": "✅ %s ha creato un nuovo Circuito chiamato %s",
|
||||
"CIRCUIT_REQUEST": "Richiesta di entrare nel Circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN_YOU": "Sei stato aggiunto come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN_YOU": "Ti è stato rimosso l'incarico di Amministratore del circuito %s da parte di %s",
|
||||
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il Circuito %s da parte di %s",
|
||||
"CIRCUIT_ELIMINATO": "Il circuito %s è stato eliminato da parte di %s",
|
||||
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Circuito %s. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
|
||||
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_REFUSED_TO_ME": "All'utente %s gli è stato rifiutato l'accesso a far parte del Circuito %s (da parte di %s).",
|
||||
"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.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "%s %s accettati da %s.",
|
||||
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa",
|
||||
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario può accumulare"
|
||||
"Hello": "Ciao",
|
||||
"Hello %s": "Ciao %s",
|
||||
"Good: %s": "Bene: %s",
|
||||
"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",
|
||||
"<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",
|
||||
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
||||
"✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !",
|
||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Gruppo %s (da parte di %s)",
|
||||
"GROUPS_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Gruppo %s. Se pensi sia un'errore, contatta l'amministratore del Gruppo.",
|
||||
"GROUPS_REMOVED": "❌ l'utente %s è stato rimosso del Gruppo %s (da parte di %s)",
|
||||
"GROUPS_EXIT_USER": "❌ l'utente %s è uscito dal Gruppo %s",
|
||||
"GROUPS_EXIT_USER_TO_ME": "❌ Sei uscito dal Gruppo %s",
|
||||
"GROUPS_REMOVED_TO_ME": "❌ Sei stato rimosso dal Gruppo %s (da parte di %s)",
|
||||
"ACCETTATO_NOTIFICA_ADMINS": "✅ l'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)",
|
||||
"GROUP_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel gruppo %s",
|
||||
"GROUP_CREATED": "✅ %s ha creato un nuovo Gruppo chiamato %s",
|
||||
"GROUP_REQUEST": "Richiesta di entrare nel Gruppo %s da parte di %s",
|
||||
"GROUPS_ADDED_ADMIN_GROUP": "E' stato aggiunto %s come Amministratore del gruppo %s da parte di %s",
|
||||
"GROUPS_ADDED_ADMIN_GROUP_YOU": "Sei stato aggiunto come Amministratore del gruppo %s da parte di %s",
|
||||
"GROUPS_REMOVED_ADMIN_GROUP": "E' stato rimosso l'incarico di Amministratore a %s del gruppo %s da parte di %s",
|
||||
"GROUPS_REMOVED_ADMIN_GROUP_YOU": "Ti è stato rimosso l'incarico di Amministratore del gruppo %s da parte di %s",
|
||||
"RICHIESTA_BLOCCO_GRUPPO": "Richiesta di bloccare il Gruppo %s da parte di %s",
|
||||
"GRUPPO_ELIMINATO": "Il gruppo %s è stato eliminato da parte di %s",
|
||||
"FRIEND_REPORTED_TO_ME": "Sei stato segnalato da %s per comportamenti non idonei. Contatta %s per chiarimenti",
|
||||
"FRIEND_REPORTED": "E' stato segnalato %s da %s per comportamenti non idonei.",
|
||||
"FRIEND_REPORTED_YOU": "Hai segnalato %s per comportamenti non idonei.",
|
||||
"FRIEND_UNBLOCKED_TO_ME": "Sei stato riattivato da %s",
|
||||
"FRIEND_UNBLOCKED": "E' stato riattivato %s da %s.",
|
||||
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Accetta Ingresso nel Circuito %s:",
|
||||
"CIRCUIT_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel circuito %s",
|
||||
"CIRCUIT_CREATED": "✅ %s ha creato un nuovo Circuito chiamato %s",
|
||||
"CIRCUIT_REQUEST": "Richiesta di entrare nel Circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN_YOU": "Sei stato aggiunto come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN_YOU": "Ti è stato rimosso l'incarico di Amministratore del circuito %s da parte di %s",
|
||||
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il Circuito %s da parte di %s",
|
||||
"CIRCUIT_ELIMINATO": "Il circuito %s è stato eliminato da parte di %s",
|
||||
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Circuito %s. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
|
||||
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_REFUSED_TO_ME": "All'utente %s gli è stato rifiutato l'accesso a far parte del Circuito %s (da parte di %s).",
|
||||
"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.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "%s %s accettati da %s.",
|
||||
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa",
|
||||
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario può accumulare",
|
||||
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
|
||||
"STATUS_SENT": "Inviato",
|
||||
"STATUS_REFUSED": "Rifiutato"
|
||||
}
|
||||
|
||||
@@ -455,6 +455,8 @@ CircuitSchema.statics.sendCoins = async function(onlycheck, idapp, usernameOrig,
|
||||
let ris = {
|
||||
cansend: true,
|
||||
errormsg: '',
|
||||
rec: null,
|
||||
useraccounts: [],
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -471,7 +473,7 @@ CircuitSchema.statics.sendCoins = async function(onlycheck, idapp, usernameOrig,
|
||||
const accountorig = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, { circuitId: reccircuit._id }, true);
|
||||
|
||||
// Check if Sender has enough money
|
||||
if (accountorig.saldo - myqty < accountorig.fidoConcesso) {
|
||||
if (accountorig.saldo - myqty < -accountorig.fidoConcesso) {
|
||||
ris.cansend = false;
|
||||
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_FIDO');
|
||||
}
|
||||
@@ -482,7 +484,9 @@ CircuitSchema.statics.sendCoins = async function(onlycheck, idapp, usernameOrig,
|
||||
|
||||
if (!onlycheck) {
|
||||
// Add a Transaction !
|
||||
ris.cansend = await Movement.addMov(idapp, accountorig, accountdest, myqty, extrarec.causal);
|
||||
ris.rec = await Movement.addMov(idapp, accountorig, accountdest, myqty, extrarec.causal);
|
||||
|
||||
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
|
||||
|
||||
if (ris.cansend) {
|
||||
console.log('Invia Monete da', usernameOrig, extrarec.dest, extrarec.qty, extrarec.causal);
|
||||
|
||||
@@ -114,6 +114,17 @@ sendNotifSchema.statics.setNotifAsRead = function(idapp, username, idnotif) {
|
||||
}
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getRecNotif = function(id) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
return SendNotif.findById(id).lean();
|
||||
}catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function(username, lastdataread, idapp) {
|
||||
const SendNotif = this;
|
||||
|
||||
@@ -259,7 +270,8 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
||||
newdescr = i18n.__('CIRCUIT_CREATED', userorig, recnotif.paramsObj.circuitnameDest);
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||
if (recnotif.paramsObj.isAdmin) {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS_CIRCUIT', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS_CIRCUIT', userorig, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_ACCEPTED', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
@@ -286,7 +298,8 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
||||
}
|
||||
tag = 'refcircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER) {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.singleadmin_username);
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', userorig, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.singleadmin_username);
|
||||
tag = 'reqcircuits';
|
||||
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_DELETE_USER) {
|
||||
@@ -309,11 +322,13 @@ 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, recnotif.paramsObj.extrarec.symbol);
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', 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 ?
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', recnotif.paramsObj.extrarec.qty, recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action);
|
||||
tag = 'sendcoin';
|
||||
}
|
||||
}
|
||||
@@ -402,7 +417,7 @@ sendNotifSchema.statics.saveAndSendNotif = async function(myrecnotif, req, res,
|
||||
return await globalTables.sendNotif(myrecread.typedir, myrecread.typeid, res, idapp, user ? user : req.user, myrecread);
|
||||
}
|
||||
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
return null;
|
||||
}
|
||||
@@ -423,6 +438,7 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
}
|
||||
|
||||
let newstatus = 0;
|
||||
let idnotiftosearch = '';
|
||||
let typeidsearch = 0;
|
||||
let dest = '';
|
||||
|
||||
@@ -453,6 +469,7 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_DELETED;
|
||||
}
|
||||
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
|
||||
idnotiftosearch = myrecnotif.paramsObj.extrarec.notifId;
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||
dest = myrecnotif.dest;
|
||||
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||
@@ -483,7 +500,7 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
descr: myrecnotif.descr,
|
||||
};
|
||||
|
||||
const query = {
|
||||
let query = {
|
||||
idapp: myrecnotif.idapp,
|
||||
typedir: myrecnotif.typedir,
|
||||
typeid: typeidsearch,
|
||||
@@ -492,6 +509,13 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
status: 0,
|
||||
};
|
||||
|
||||
if (idnotiftosearch) {
|
||||
query = {
|
||||
_id: idnotiftosearch,
|
||||
status: 0,
|
||||
};
|
||||
}
|
||||
|
||||
// Cerca il record e se lo trova lo aggiorna
|
||||
const myrec = await SendNotif.findOneAndUpdate(query, {$set: fields_to_update}, {
|
||||
new: true,
|
||||
@@ -516,11 +540,43 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getStatus = async function(notifId) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
return await SendNotif.findOne({_id: notifId}, {status: 1}).lean().then((rec) => rec.status);
|
||||
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
const status = await SendNotif.getStatus(notifId);
|
||||
|
||||
if (status !== null) {
|
||||
return (status === shared_consts.CircuitsNotif.STATUS_ACCEPTED) ||
|
||||
(status === shared_consts.CircuitsNotif.STATUS_REFUSED);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (e) {
|
||||
// If Error, don't send the coins
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.saveNotif = async function(myrecnotif) {
|
||||
|
||||
const SendNotif = this;
|
||||
|
||||
const {myrecout, save} = await SendNotif.updateStatusAndDescr(myrecnotif, true);
|
||||
const {myrecout, save} = await SendNotif.updateStatusAndDescr(myrecnotif, true);
|
||||
if (!myrecout)
|
||||
return null;
|
||||
|
||||
@@ -734,7 +790,9 @@ sendNotifSchema.statics.sendToSingleUserDest = async function(myrecnotif, req, r
|
||||
try {
|
||||
|
||||
myrecnotif.dest = myrecnotif.paramsObj && myrecnotif.paramsObj.usernameDest ? myrecnotif.paramsObj.usernameDest : '';
|
||||
myrecnotif.username_worked = myrecnotif.paramsObj && myrecnotif.paramsObj.username_worked ? myrecnotif.paramsObj.username_worked : myrecnotif.dest;
|
||||
myrecnotif.username_worked = myrecnotif.paramsObj && myrecnotif.paramsObj.username_worked
|
||||
? myrecnotif.paramsObj.username_worked
|
||||
: myrecnotif.dest;
|
||||
|
||||
if (onlysave) {
|
||||
await SendNotif.saveNotif(myrecnotif);
|
||||
|
||||
@@ -2081,6 +2081,8 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
||||
|
||||
UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitname, cmd, value, username_action, extrarec) {
|
||||
|
||||
const {SendNotif} = require('../models/sendnotif');
|
||||
|
||||
let ris = null;
|
||||
let update = {};
|
||||
try {
|
||||
@@ -2197,28 +2199,52 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
|
||||
ris = await Circuit.removeAdminOfCircuit(idapp, usernameOrig, circuitname); // Rimuovo la richiesta di entrare nel gruppo
|
||||
w
|
||||
|
||||
// Invia una notifica alla persona
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||
|
||||
let ris = await Circuit.sendCoins(true, idapp, usernameOrig, extrarec);
|
||||
if (ris.cansend) {
|
||||
let ris2 = await Circuit.sendCoins(true, idapp, usernameOrig, extrarec);
|
||||
if (ris2.cansend) {
|
||||
// Invia una notifica di moneta alla persona
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
|
||||
} else {
|
||||
ris.cansend = false;
|
||||
ris2.cansend = false;
|
||||
}
|
||||
|
||||
ris = ris2;
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||
ris = await Circuit.sendCoins(false, idapp, usernameOrig, extrarec);
|
||||
// Before to accept, I see if it's already set !
|
||||
|
||||
if (ris.cansend) {
|
||||
// Invia una notifica di moneta alla persona
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
|
||||
let ris2 = {
|
||||
cansend: false,
|
||||
errormsg: '',
|
||||
};
|
||||
|
||||
let risStatus = '';
|
||||
const status = await SendNotif.getStatus(extrarec.notifId);
|
||||
if (status === shared_consts.CircuitsNotif.STATUS_ACCEPTED) {
|
||||
risStatus = i18n.__('STATUS_SENT');
|
||||
} else if (status === shared_consts.CircuitsNotif.STATUS_REFUSED) {
|
||||
risStatus = i18n.__('STATUS_REFUSED');
|
||||
}
|
||||
if (!await SendNotif.checkIfCoinsAlreadySent(extrarec.notifId)) {
|
||||
ris2 = await Circuit.sendCoins(false, idapp, usernameOrig, extrarec);
|
||||
|
||||
if (ris2.cansend) {
|
||||
// Invia una notifica di moneta alla persona
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
|
||||
}
|
||||
|
||||
ris2.recnotif = await SendNotif.getRecNotif(extrarec.notifId);
|
||||
} else {
|
||||
ris2.cansend = false;
|
||||
|
||||
ris2.errormsg = i18n.__('CIRCUIT_COINS_ALREADY_PROCESSED', risStatus);
|
||||
}
|
||||
ris = ris2;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error setCircuitCmd: ', e);
|
||||
|
||||
@@ -712,7 +712,7 @@ router.post('/groups/cmd', authenticate, (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/circuits/cmd', authenticate, (req, res) => {
|
||||
router.post('/circuits/cmd', authenticate, async (req, res) => {
|
||||
const usernameLogged = req.user.username;
|
||||
const idapp = req.body.idapp;
|
||||
const locale = req.body.locale;
|
||||
@@ -730,9 +730,14 @@ router.post('/circuits/cmd', authenticate, (req, res) => {
|
||||
}
|
||||
}*/
|
||||
|
||||
return User.setCircuitCmd(idapp, usernameOrig, circuitname, cmd, value, usernameLogged, extrarec).
|
||||
return await User.setCircuitCmd(idapp, usernameOrig, circuitname, cmd, value, usernameLogged, extrarec).
|
||||
then((ris) => {
|
||||
res.send(ris);
|
||||
|
||||
// Check if ìs a Notif to read
|
||||
const idnotif = extrarec['idnotif'] ? extrarec['idnotif'] : '';
|
||||
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
|
||||
|
||||
return res.send(ris);
|
||||
}).
|
||||
catch((e) => {
|
||||
tools.mylog('ERRORE IN circuits/cmd: ' + e.message);
|
||||
|
||||
Reference in New Issue
Block a user